xcode中的动画颜色混合
问题描述:
我一直在一个简单的动画上工作几个小时,但似乎没有任何工作适合我。xcode中的动画颜色混合
我需要在UILabel中显示一个价格,很简单! 但是,当提供布尔值设置为true时,UIView所在UIView的背景应该从红色到黄色混合,然后回到无限循环。这是因为它是一个特殊的价格,应该是用户的“捕手”。任何人都可以帮我解决这个问题吗?
谢谢你们:-)
答
你可以使用一个基本的动画来实现这一点。
本质上添加一个动画到UILabel的层,从到的值改变颜色和具有它扭转。类似于:
CABasicAnimation *theAnimation;
theAnimation=[CABasicAnimation animationWithKeyPath:@"backgroundColor"];
theAnimation.duration=1;
theAnimation.repeatCount= UINT32_MAX;
theAnimation.autoreverses = YES;
theAnimation.fromValue= <YOUR COLOR VALUE 1>
theAnimation.toValue= <YOUR COLOR VALUE 2>
[label.layer addAnimation:theAnimation forKey:@"animateLayer"];
+0
需要输入颜色值作为CGColor –
+0
感谢logoncautrell –
你已经试过了什么?结果是什么?你期望看到什么?尝试发布代码和截图。 http://msmvps.com/blogs/jon_skeet/archive/2010/08/29/writing-the-perfect-question.aspx – occulus