Chompas
Chompas

Reputation: 563

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

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

Upvotes: 0

Views: 2283

Answers (1)

David Neiss
David Neiss

Reputation: 8237

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 
];

Upvotes: 4

Related Questions