On iOS7, we can changing navigation bar's color by
self.navigationController.navigationBar.barTintColor = [UIColor redColor];
But this method has a fade animation when changing the barTintColor, So does anynone know how to prevent this animation and change the color immediately?
To be more specific, I wrote a test program whose window's root controller is navigationController. And in the navigationController, there is a view controller with 3 buttons. 3 buttons all bind to the following action:
- (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];
}
Both changing the animation duration to 0 or using [CATransaction setDisableActions:YES]
doesn't work, the animation still exists.
Hope someone can help, thank you!
Try with