I am trying to change the color of the navigation bar when I click the view controller in the navigation stack using barTintColor while navigating the Controller (_: willShow: animated :).
Here is the code:
func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) { if viewController is ViewerViewController { navigationBar.barTintColor = UIColor(custom: .white) navigationBar.tintColor = UIColor(custom: .black) } else if viewController is FeedViewController { navigationBar.barTintColor = UIColor(custom: .blue) navigationBar.tintColor = UIColor(custom: .white) } }
Everything works beautifully when I press the view controller, and when I use the rewind gesture (the color transition is smooth in both directions).
However, when I press the back button , the color does not change at first, it goes to navigation, and then the color changes without animation ... p>
Has anyone already encountered / resolved this issue? Any key would be appreciated.
source share