【发布时间】:2014-01-10 10:14:32
【问题描述】:
在iOS7上,我们可以通过改变导航栏的颜色
self.navigationController.navigationBar.barTintColor = [UIColor redColor];
但是这个方法在改变barTintColor的时候有一个淡入淡出的动画,那么有没有人知道如何阻止这个动画并立即改变颜色呢?
更具体地说,我编写了一个测试程序,其窗口的根控制器是navigationController。在 navigationController 中,有一个带有 3 个按钮的视图控制器。 3 个按钮都绑定到以下操作:
- (void)onClick:(id)sender
{
UIColor *color = nil;
if (sender == self.redButton)
{
color = [UIColor redColor];
}
else if (sender == self.blueButton)
{
color = [UIColor blueColor];
}
else if (sender == self.blackButton)
{
color = [UIColor blackColor];
}
self.navigationController.navigationBar.barTintColor = color
// [UIView animateWithDuration:0 animations:^{
// self.navigationController.navigationBar.barTintColor = color;
// }];
// [CATransaction begin];
// [CATransaction setDisableActions:YES];
// self.navigationController.navigationBar.barTintColor = color;
// [CATransaction commit];
}
将动画持续时间更改为 0 或使用[CATransaction setDisableActions:YES] 都不起作用,动画仍然存在。
希望有人能帮忙,谢谢!
【问题讨论】:
标签: ios ios7 uinavigationbar bartintcolor