码迷,mamicode.com
首页 > 移动开发 > 详细

iOS实现跑马灯效果

时间:2015-03-09 16:05:18      阅读:162      评论:0      收藏:0      [点我收藏+]

标签:

在网页开发当中跑马灯是常用到的,用来显示通知等,在游戏开发当中也如此。

下面的代码片断可实现iOS中的跑马灯效果,

 

  1. [labelShow sizeToFit];   
  2. CGRect frame = labelShow.frame;  
  3. frame.origin.x = 320;  
  4. labelShow.frame = frame;  
  5.   
  6. [UIView beginAnimations:@"testAnimation" context:NULL];  
  7. [UIView setAnimationDuration:8.8f];    
  8. [UIView setAnimationCurve:UIViewAnimationCurveLinear];    
  9. [UIView setAnimationDelegate:self];    
  10. [UIView setAnimationRepeatAutoreverses:NO];    
  11. [UIView setAnimationRepeatCount:999999];   
  12.   
  13. frame = labelShow.frame;  
  14. frame.origin.x = -frame.size.width;  
  15. labelShow.frame = frame;  
  16. [UIView commitAnimations];    


labelShow是UILabel,关联到xib就行了。

iOS实现跑马灯效果

标签:

原文地址:http://www.cnblogs.com/xmqxml/p/4323612.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!