成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

IOS應用程序跑馬燈效果案例

移動開發 iOS
本文介紹的是IOS應用程序跑馬燈效果案例,通過代碼很認真的完成了跑馬燈的任務,先來看詳細代碼內容。

IOS應用程序跑馬燈效果案例是本文要介紹的內容,內容不多,主要是以代碼實現跑馬燈效果的內容。先來看詳細內容。最新項目中要求實現web頁面中常有的跑馬燈效果來顯示廣告內容。ios中沒有提供相應的api,下面是利用NSTimer和NSLable實現的一個跑馬燈效果。界面如下:

IOS應用程序跑馬燈效果案例

實現的代碼如下:

  1. #import "AdvertisingView.h"   
  2. #import <QuartzCore/QuartzCore.h>   
  3. @implementation AdvertisingView   
  4. @synthesize myArray;   
  5. - (id)initWithFrame:(CGRect)frame {   
  6.     self = [super initWithFrame:frame];   
  7.     if (self) {   
  8.         [self setBackgroundColor:[UIColor clearColor]];   
  9.         if (myAdView==nil) {   
  10.             myAdView=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 188, 33)];   
  11.             [myAdView setClipsToBounds:YES];   
  12.             if (myLable==nil) {   
  13.                 myLable=[[UILabel alloc] initWithFrame:CGRectMake(0, 23, 175, 33)];   
  14.                 [myLable setFont:[UIFont fontWithName:@"Helvetica" size:10.0]];   
  15.                 [myLable setNumberOfLines:0];   
  16.                 [myLable setBackgroundColor:[UIColor clearColor]];   
  17.                 [myAdView addSubview:myLable];   
  18.             }   
  19.             [myAdView setBackgroundColor:[UIColor clearColor]];   
  20.             [self addSubview:myAdView];   
  21.         }   
  22.     }   
  23.     return self;   
  24. }   
  25. - (void)dealloc {   
  26.     [[NSNotificationCenter defaultCenter] removeObserver:self];   
  27.     if (timer!=nil&&[timer isValid]) {   
  28.         [timer invalidate];   
  29.         timer=nil;   
  30.     }   
  31.     self.myArray=nil;   
  32.     [self.myArray release];   
  33.     myAdView=nil;   
  34.     [myAdView release];   
  35.     myLable=nil;   
  36.     [myLable release];   
  37.     [super dealloc];   
  38. }   
  39. -(void)addAdvertisingList   
  40. {   
  41.     //數據層   
  42.     self.myArray=[[NSMutableArray alloc] initWithCapacity:1];   
  43.     [self.myArray addObject:@"大家好"];   
  44.     [self.myArray addObject:@"We are pleased to announce that the fourth milestone release of the Spring Android project is now available!"];   
  45.     [self.myArray addObject:@"Support for Spring Social 1.0.0.RC1, and Spring Security 3.1.0.RC2 through the Spring Android Auth module,
  46.  which includes a SQLite datastore for persisting OAuth API connections."];   
  47.     if ([self.myArray count]) {   
  48.         [myLable setText:@""];   
  49.         NSString *text=nil;   
  50.         for ( int i=0; i<[self.myArray count]; i++) {   
  51.             if (i==0) {   
  52.                 text=[self.myArray objectAtIndex:i];   
  53.             }else{   
  54.                 text=[NSString stringWithFormat:@"%@\n%@",text,[self.myArray objectAtIndex:i]];   
  55.             }   
  56.         }   
  57.         UIFont *font = [UIFont fontWithName:@"Helvetica" size:10.0];   
  58.         CGSize size = [text sizeWithFont:font constrainedToSize:CGSizeMake(175.0f, 2000.0f) lineBreakMode:UILineBreakModeWordWrap];   
  59.         CGRect rect=myLable.frame;   
  60.         rect.size=size;   
  61.         [myLable setFrame:rect];   
  62.         [myLable setText:text];   
  63.         if (timer==nil) {   
  64.             timer=[NSTimer scheduledTimerWithTimeInterval: 0.05   
  65.                                                    target: self   
  66.                                                  selector: @selector(handleTimer:)   
  67.                                                  userInfo: nil   
  68.                                                   repeats: YES];    
  69.         }   
  70.     }   
  71. }   
  72. -(void)handleTimer:(id)sender   
  73. {   
  74.     if ([self.myArray count]>0) {   
  75.         CGRect newFrame1 = myLable.frame;   
  76.         if (newFrame1.origin.y<-newFrame1.size.height) {   
  77.             newFrame1.origin.y = 23;   
  78.             [myLable setFrame:newFrame1];   
  79.         }else {   
  80.             newFrame1newFrame1.origin.y =  newFrame1.origin.y-0.8;   
  81.             [myLable setFrame:newFrame1];   
  82.         }      
  83.     }   
  84. }   
  85. -(void)drawMainLable:(CGRect)newFrame   
  86. {   
  87.     CGRect newFrame1 = myLable.frame;   
  88.     newFrame1newFrame1.origin.y =  newFrame1.origin.y+50;   
  89.     [myLable setFrame:newFrame1];   
  90. }   
  91. @end 

源代碼:http://easymorse-iphone.googlecode.com/svn/trunk/scrollLayer/

小結:IOS應用程序跑馬燈效果案例的內容介紹完了,希望本文對你有所幫助!

責任編輯:zhaolei 來源: 互聯網
相關推薦

2015-08-07 15:45:02

swift跑馬燈源碼

2013-01-14 17:18:43

Android開發TextView跑馬燈效果

2022-07-12 08:32:17

transition跑馬燈

2023-11-01 08:33:45

CSS動畫效果

2021-01-28 14:34:35

鴻蒙HarmonyOS應用開發

2021-01-29 09:48:17

鴻蒙HarmonyOS應用開發

2011-07-21 16:19:30

iOS Twitter

2025-04-14 09:35:00

2017-11-10 11:04:29

NVIDIA TITA處理器典藏版

2011-07-28 15:47:20

IOS 程序 測試

2015-07-09 15:42:48

ios應用生命周期

2011-05-31 15:41:00

Cocoa TouchCocoaiOS

2011-05-11 10:58:39

iOS

2011-07-07 17:23:31

iOS

2011-07-28 16:06:34

IOS 應用程序 資源

2014-04-02 09:56:13

iOS應用減小安裝包

2013-01-11 14:45:43

iOS開發移動應用iPhone

2015-12-09 14:00:41

ios應用

2011-07-06 10:22:31

XCode IOS object-C

2018-10-25 15:13:23

APP脫殼工具
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: av网站在线免费观看 | 欧美性成人| 亚洲欧美日韩中文在线 | 日韩2020狼一二三 | 中文在线a在线 | 国产污视频在线 | 久草视频在线播放 | 一二区电影 | 久久99国产精品久久99果冻传媒 | 欧美视频三级 | 国产视频一区二区在线观看 | 九九视频网 | 婷婷色网| 久久综合九色综合欧美狠狠 | 国产精品欧美精品 | 91精品国产综合久久久久久漫画 | 欧美一区二区三区四区视频 | 欧美日韩精品亚洲 | 久久久久久久久久久久亚洲 | 日韩成人国产 | 国产高清在线精品 | 日韩欧美在线观看一区 | 国产日韩一区二区三区 | 91不卡 | 一级黄色影片在线观看 | 国产精品v | 最新超碰 | 中文字幕免费 | 欧美性jizz18性欧美 | 福利视频网站 | 99精品欧美一区二区三区综合在线 | 亚洲欧美中文字幕在线观看 | 国产精品99一区二区 | 亚洲 中文 欧美 日韩 在线观看 | 成人午夜视频在线观看 | 欧美aⅴ| 久久精品国产一区二区三区 | 亚洲日本视频 | 一级片在线观看 | www一级片 | 国产精品久久久久久久久久免费看 |