导航栏闪烁

时间:2014-12-31 12:16:28

标签: ios objective-c xcode uinavigationbar caanimation

我正在尝试让我的导航栏有一个闪烁动画,以显示背景中正在发生的事情。问题是颜色太浅了,我为动画添加了一种纯色,但在设备上它只显示了一些几乎没有注意到的颜色变化。

以下是代码:

CABasicAnimation *anAnimation = [CABasicAnimation animationWithKeyPath:@"backgroundColor"];
anAnimation.duration = 3.00;
anAnimation.repeatCount = HUGE_VAL;
anAnimation.autoreverses = YES;
anAnimation.fromValue = (id)[[UIColor whiteColor] CGColor];
anAnimation.toValue = (id)[[UIColor blueColor] CGColor];
[self.navigationController.navigationBar.layer addAnimation:anAnimation forKey:@"backgroundColor"];

先谢谢。

1 个答案:

答案 0 :(得分:0)

尝试添加导航栏图层的子图层并在其中添加动画。如果将动画添加到“主”图层,某些自定义绘图可能会破坏动画。 请注意,导航栏的颜色是使用barTintColor属性设置的,该属性可能与引擎盖下的视图/图层的backgroundColor不同。