简体   繁体   中英

Change the color of UIView Object Reference while it is animating

I have a drawn a view in my xib file. 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. 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...). 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM