How can I fade from one background color to another color in a UIView?
In javascript (jQuery), this can be done by doing the following:
$('body').animate({ backgroundColor: "#ff00ff"});
Would it be easier if I converted the colors to HSV?
EDIT: Tried to do this with CABasicAnimation, but for unknown reasons it runs white.: /
CABasicAnimation* fade = [CABasicAnimation animationWithKeyPath:@"backgroundColor"]; fade.fillMode = kCAFillModeForwards; fade.removedOnCompletion = NO;
Then I tried to find another way to do this and came across "implicit animation". The following works with good second attenuation:
[UIView beginAnimations:@"fade" context:nil]; [UIView setAnimationDuration:1]; [[self view] setBackgroundColor: [UIColor greenColor]]; [UIView commitAnimations];
Thanks, StackOverflow, for helping everyone learn even more. :)
source share