我想要通过动画来实现uilabel的背景颜色渐变效果。我的代码如下:
UILabel *lbl = ...
UIColor *oldCol = lbl.backgroundColor;
lbl.backgroundColor = [UIColor blueColor];
[UIView animateWithDuration:1.0 animations:^(void) {
lbl.backgroundColor = oldCol;
}];
但它立即恢复到原来的颜色。我还尝试了以下方法,以隔离问题:
lbl.backgroundColor = [UIColor blueColor];
[UIView animateWithDuration:1.0 animations:^(void) {
lbl.backgroundColor = [UIColor greenColor];
}];
并且它立即变为绿色。有任何想法吗?