UIcolor *fromcolor = [UIcolor redcolor];UIcolor *tocolor = [UIcolor yellowcolor];CABasicAnimation *colorAnimation = [CABasicAnimation animationWithKeyPath:@"backgroundcolor"];colorAnimation.duration = 1.0;colorAnimation.fromValue = (ID)fromcolor.CGcolor;colorAnimation.tovalue = (ID)tocolor.CGcolor;
此示例在1秒内将背景颜色从红色淡化为黄色.
直接从Apple’s example code获取的另一个例子:
CAKeyframeAnimation* colorAnim = [CAKeyframeAnimation animationWithKeyPath:@"bordercolor"];NSArray* colorValues = [NSArray arrayWithObjects:(ID)[UIcolor greencolor].CGcolor,(ID)[UIcolor redcolor].CGcolor,(ID)[UIcolor bluecolor].CGcolor,nil];colorAnim.values = colorValues;colorAnim.calculationMode = kCAAnimationPaced;总结
以上是内存溢出为你收集整理的iPhone – 如何为CABasicAnimation设置颜色?全部内容,希望文章能够帮你解决iPhone – 如何为CABasicAnimation设置颜色?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)