This looks like it should work, but doesn't. The color turns green at once.
self.labelCorrection.backgroundColor = [UIColor whiteColor];
[UIView animateWithDuration:2.0 animations:^{
self.labelCorrection.backgroundColor = [UIColor greenColor];
}];
I can't find it documented anywhere, but it appears the backgroundColor
property of UILabel
is not animatable, as your code works fine with a vanilla UIView
. This hack appears to work, however, as long as you don't set the background color of the label view itself:
#import <QuartzCore/QuartzCore.h>
...
theLabel.layer.backgroundColor = [UIColor whiteColor].CGColor;
[UIView animateWithDuration:2.0 animations:^{
theLabel.layer.backgroundColor = [UIColor greenColor].CGColor;
} completion:NULL];