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

IOS應(yīng)用程序跑馬燈效果案例

移動開發(fā) iOS
本文介紹的是IOS應(yīng)用程序跑馬燈效果案例,通過代碼很認真的完成了跑馬燈的任務(wù),先來看詳細代碼內(nèi)容。

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

IOS應(yīng)用程序跑馬燈效果案例

實現(xiàn)的代碼如下:

  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.     //數(shù)據(jù)層   
  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/

小結(jié):IOS應(yīng)用程序跑馬燈效果案例的內(nèi)容介紹完了,希望本文對你有所幫助!

責(zé)任編輯:zhaolei 來源: 互聯(lián)網(wǎng)
相關(guān)推薦

2015-08-07 15:45:02

swift跑馬燈源碼

2013-01-14 17:18:43

Android開發(fā)TextView跑馬燈效果

2022-07-12 08:32:17

transition跑馬燈

2023-11-01 08:33:45

CSS動畫效果

2021-01-28 14:34:35

鴻蒙HarmonyOS應(yīng)用開發(fā)

2021-01-29 09:48:17

鴻蒙HarmonyOS應(yīng)用開發(fā)

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應(yīng)用生命周期

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 應(yīng)用程序 資源

2014-04-02 09:56:13

iOS應(yīng)用減小安裝包

2013-01-11 14:45:43

iOS開發(fā)移動應(yīng)用iPhone

2015-12-09 14:00:41

ios應(yīng)用

2018-10-25 15:13:23

APP脫殼工具

2011-07-06 10:22:31

XCode IOS object-C
點贊
收藏

51CTO技術(shù)棧公眾號

主站蜘蛛池模板: 国产午夜视频 | 久久久www成人免费精品 | 国产精品一区三区 | 日韩在线视频一区二区三区 | 精品久久ai电影 | 成年人在线观看 | 成人免费看片 | 午夜播放器在线观看 | 四色永久 | 国产一区91精品张津瑜 | 成年人国产在线观看 | 成人在线视频免费观看 | 欧美涩涩网 | 日韩欧美在线视频观看 | 最新日韩精品 | 亚洲一区视频 | 国产美女永久免费无遮挡 | 国产高清一二三区 | 天天躁日日躁狠狠躁2018小说 | 日韩久久网| 欧美精品久久久 | 欧美一区二区三区久久精品视 | 欧美簧片| 欧美一区二区在线看 | 国产91久久精品一区二区 | 精品欧美乱码久久久久久 | 亚洲啪啪 | 国产欧美一区二区三区另类精品 | 狠狠爱免费视频 | 国产不卡一区 | 欧美日韩久久 | 美女国内精品自产拍在线播放 | 亚洲一区二区久久 | 久久精品久久久 | 日韩高清在线 | 欧美日本韩国一区二区三区 | 日韩在线精品视频 | 国产精品美女久久久 | 一级片毛片 | 中文字幕一区二区三区不卡 | 婷婷中文字幕 |