user31231234124 user31231234124 - 16 days ago 9
iOS Question

Animating color changes from top to bottom and vice versa

Im trying to animate color change as follows:

[UIView animateWithDuration:1.0 delay:0.2 options:UIViewAnimationOptionCurveEaseIn animations:^{
self.view.backgroundColor = [UIColor greenColor];
} completion:^(BOOL finished)
{
NSLog(@"Color transformation Completed");
[UIView animateWithDuration:1.0 delay:0.2 options:UIViewAnimationOptionCurveEaseOut animations:^{
self.view.backgroundColor = [UIColor whiteColor];
} completion:^(BOOL finished)
{
NSLog(@"Color transformation Completed");
}

];
}
];


I want the color to flow from top to bottom as it fills the entire screen with green color and it should fill from bottom to top with white color.

So I have used
UIViewAnimationOptionCurveEaseIn
while filling green and
options:UIViewAnimationOptionCurveEaseOut
while filling with white but Im unable to get the desired effect..why so?

Cee Cee
Answer

options only describes how your animations would act as. For example, EaseIn means the speed of the animation is slow at first then fast.

So if you'd like to implement this animation, you can set 2 UIViews with green and white color, then change their frames through animation.