I upgraded to XCode 8.0 / iOS 10 and now the color change animation of my navigation bar is not working anymore, it changes the color directly without any animation.
<
To animate navigationBar’s color change in iOS10 you need to call layoutIfNeeded
after setting color inside animation block.
Example code:
UIView.animateWithDuration(0.5) {
self.navigationController?.navigationBar.barTintColor = UIColor.redColor()
self.navigationController?.navigationBar.layoutIfNeeded()
}
Also I want to inform that Apple doesn’t officialy support animations in such properties like barTintColor, so that method can break at any time.
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.