[英]Change the color of UIView Object Reference while it is animating
I have a drawn a view in my xib file. 我在xib文件中绘制了一个视图。 I want it to change its color while it is being animated. 我希望它在动画时更改其颜色。 Animation is working. 动画正在工作。 But I cant find to change the color of the Object. 但是我找不到改变对象的颜色。 Please help me with this. 请帮我解决一下这个。 I'm totally new to ios. 我对ios完全陌生。 Thanx in advance. 提前感谢。
在您的UIView
动画过程中编写以下代码。
YourView.backgroundColor = [UIColor redColor];
Try this. 尝试这个。
[UIView animateWithDuration:2.0 animations:^ {
//other animations
self.view.backgroundColor = [UIColor redColor];
}
completion:nil];
I don't think you can animate color like that (with animateWithDuration...). 我认为您不能像使用animateWithDuration ...那样对颜色进行动画处理。 You would have to use a timer and iterate over a series of colors. 您将必须使用计时器并遍历一系列颜色。 You could use colorWithHue:saturation:brightness:alpha: for instance, and increment the hue value. 例如,您可以使用colorWithHue:saturation:brightness:alpha:并增加色相值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.