这个看起来应该可以用,但是不行. colored颜色 立刻变成了绿色.
self.labelCorrection.backgroundColor = [UIColor whiteColor];
[UIView animateWithDuration:2.0 animations:^{
self.labelCorrection.backgroundColor = [UIColor greenColor];
}];
这个看起来应该可以用,但是不行. colored颜色 立刻变成了绿色.
self.labelCorrection.backgroundColor = [UIColor whiteColor];
[UIView animateWithDuration:2.0 animations:^{
self.labelCorrection.backgroundColor = [UIColor greenColor];
}];
我在任何地方都找不到它的文档,但是看起来UILabel
的backgroundColor
属性是不可动画的,因为您的代码在普通的UIView
上运行得很好.但是,只要您不设置标签视图本身的背景色,这种攻击就会奏效:
#import <QuartzCore/QuartzCore.h>
...
theLabel.layer.backgroundColor = [UIColor whiteColor].CGColor;
[UIView animateWithDuration:2.0 animations:^{
theLabel.layer.backgroundColor = [UIColor greenColor].CGColor;
} completion:NULL];