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

【代码笔记】iOS-字体从右向左滚动

时间:2017-07-19 17:46:41      阅读:241      评论:0      收藏:0      [点我收藏+]

标签:class   idt   channel   ons   style   bsp   void   nim   call   

一,效果图。

技术分享

二,代码。

ViewController.m

技术分享
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    //上面的滚动条
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(5, 50, 500, 40)];
    label.text=@"111111111111122222222";
    label.backgroundColor=[UIColor redColor];
    [self.view addSubview:label];
    
    //从右到左滚动
    [self AnimationWithLabel:label];
}

//使字体从右向左滚动
- (void)AnimationWithLabel:(UILabel*)labelShow;
{
    CGRect frame = labelShow.frame;
    frame.origin.x = W;
    labelShow.frame = frame;
    [UIView beginAnimations:@"testAnimation" context:NULL];
    [UIView setAnimationDuration:6.0f];
    [UIView setAnimationCurve:UIViewAnimationCurveLinear];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationRepeatAutoreverses:NO];
    [UIView setAnimationRepeatCount:9999999999];
    frame = labelShow.frame;
    frame.origin.x = -290;
    labelShow.frame = frame;
    [UIView commitAnimations];
}
技术分享

 

 

【代码笔记】iOS-字体从右向左滚动

标签:class   idt   channel   ons   style   bsp   void   nim   call   

原文地址:http://www.cnblogs.com/yang-guang-girl/p/7206587.html

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