开发者

iphone - UIAnimation Fade Between two colors like "Touch to return to call" box

开发者 https://www.devze.com 2023-03-03 07:44 出处:网络
I have a UIView with a label inside that appears at the bottom of my app. I\'m trying to create an animation like the one that appears when you are in a call and touch the home button.

I have a UIView with a label inside that appears at the bottom of my app. I'm trying to create an animation like the one that appears when you are in a call and touch the home button.

It seems like a fade transition that loops between two colors (light green and strong green in the call box).

I also have a NStimer that I think I could use开发者_开发百科 for looping this.

Any ideas in how to accomplish?

Thanks in advance


Background color is supposed to be animatable (however, as others have found UILabel doesn't seem to support that, but other views do). Try that and see where it takes you. I think you could dig down to CA layer keyframes to control the color stepping.

You might also try having one layer with one color and another colored layer on top of that and animating the alpha of the top layer.

UIView *v = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
[window addSubview:v];
[v setBackgroundColor:[UIColor blueColor]];

[UIView animateWithDuration:1 
delay:0 
options:UIViewAnimationOptionAutoreverse                
animations:^
{
    v.backgroundColor = [UIColor redColor];
}
completion:nil 
];
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号