首页 > 移动平台 > 详细

iOS实现跑马灯效果

时间:2015-03-09 16:03:52      阅读:442      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!