首页 > 移动平台 > 详细

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

时间:2017-07-19 17:03:40      阅读:352      评论:0      收藏:0      [点我收藏+]

一,效果图。

技术分享

二,代码。

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-字体从右向左滚动

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!