UILabel的实际动画是什么?

bio*_*ffe 5 iphone cocoa-touch core-animation uikit

我试图为backgroundColorUILabel类的属性设置动画并且到目前为止都没有成功.这是我的代码片段

-(void) blink {
  UIColor* originalColor = lblDescription.backgroundColor;
  lblDescription.backgroundColor = [UIColor yellowColor];

  [UIView beginAnimations:nil context:NULL];
  [UIView setAnimationDuration:1.0];
  lblDescription.backgroundColor = originalColor;
  [UIView commitAnimations];
}
//this code works if lblDescription is UIView and does not if UILabel
Run Code Online (Sandbox Code Playgroud)

我发现了一些要求,一些的UILabel属性不是动画,但我无法通过阅读苹果文档证实这种说法.我想知道是否有人可以解释这个问题.

小智 4

iOS 视图编程指南的此页面上,“表 1-2\xc2\xa0Animatable 属性”据称列出了 UIView 的所有可动画属性。它不包括背景颜色。

\n\n

但在 UIView 类参考中,在 backgroundColor 属性下它说:

\n\n
\n

讨论
\n 对此属性的更改可以进行动画处理。默认为零。

\n
\n\n

所以不清楚为什么 UILabel 的背景颜色没有动画。

\n\n

我过去使用的解决方法是使用 CATextLayer 而不是 UILabel。

\n