码迷,mamicode.com
首页 > 其他好文 > 详细

一个动画 Label (走马观花)

时间:2015-05-26 20:47:10      阅读:96      评论:0      收藏:0      [点我收藏+]

标签:

 

UILabel中一个水平移动的Label

UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 300, 300)];

    UILabel *label7 = [[UILabel alloc]initWithFrame:CGRectMake(50.0, 380.0, 200.0, 50.0)];

    label.text = @"啦啦啦拉拉,阿拉拉啊 ......";

    label.backgroundColor = [UIColor blackColor];

    label.textAlignment = UIBaselineAdjustmentAlignCenters;

    label.textColor = [UIColor whiteColor];

    [label7 setShadowColor:[UIColor redColor]];

    label7.shadowOffset = CGSizeMake(1.0, 1.0);

    CGRect frame = label7.frame;//一个矩形与Label7 一样的长

    frame.origin.x = -180;//这个矩形在父视图中X轴的开始动画位置

    label.frame = frame;

    [UIView beginAnimations:@"testAnimation" context:NULL];//开始动画

    [UIView setAnimationDuration:8.8f];//设置动画持续的时间(速率)

    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.window cache:YES];//设置动画的翻转方式

    [UIView setAnimationDelegate:self];//设置动画的运行的位置

    [UIView setAnimationRepeatAutoreverses:YES];//是不是设置为自动反向运动

    [UIView setAnimationRepeatCount:999999];//动画播放的次数

    frame = label.frame;

    frame.origin.x = 350;//矩形在父视图运动距离

    label.frame = frame;

    [UIView commitAnimations];

    

    [self.window addSubview:label];

    [label release];

    

一个动画 Label (走马观花)

标签:

原文地址:http://www.cnblogs.com/meixian/p/4531430.html

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