UINavigationBar BarTintColor Not Animating

I am trying to animate the changing of the bar tint color of a UINavigationBar. However, it does not seem to animation in iOS 10.


Here is my code.

[UIView animateWithDuration:0.3 animations:^{
     self.navigationController.navigationBar.barTintColor = [UIColor whiteColor];
     self.navigationController.navigationBar.tintColor = [UIColor blackColor];
     self.navigationController.navigationBar.titleTextAttributes = @{ NSForegroundColorAttributeName : [UIColor blackColor] };
} completion:nil];


Anyone else running into this issue?

Replies

I can confirm I'm seeing this same issue too, with Xcode 8 beta 6.

Have you found any workaround?


I filed this open radar: http://www.openradar.me/radar?id=5029370750042112

I also have filed issue at bugreport.apple.com.

Same issue, Xcode 8 GM Seed.

I've worked around this by adding a colored view to the back of the navigationbar when the view controller in questions calls viewDidAppear, and remove the same view in viewDidDisappear. You can then animate this view at your hearts content.

Please don't add subviews to view hierachies you don't control.


If you call -layoutIfNeeded on the navigation bar during the animation block it should update its background properties, but given the nature of what these properties do, there really hasn't ever been any kind of guarantee that you could animate any of them.

Thanks for the reply!

The workaround was put in place as a hotfix until I had a working solution. Needed the app to look good for a sprint demo 😉


Your solution, however, fixed the problem.


Cheers,

Andreas

In case you didn't see Rincewind's reply to my post further down:


call -layoutIfNeeded on the navigation bar during the animation block