Solution for Swift 3.0 (tested on iOS 10)
Hi! I faced the same problem and finally I've found good solution.
Setting the navigation bar's color in viewWillAppear method works fine when you push from a parent to a child view. Transition between navigation bars colors is smooth.
class ChildViewController: UIViewController {
...
override func viewWillAppear(_ animated: Bool) {
self.navigationController?.navigationBar.barTintColor = UIColor.white
}
But it didn't really worked for setting the bar's color in the ParentViewController to the original one. You could notice the color's change, that looked just ugly and unprofessional.
To make the color change smooth when coming back to ParentViewController, do it within the method willMove(toParentViewController parent: UIViewController?) in your ChildViewController:
class ChildViewController: UIViewController {
...
override func willMove(toParentViewController parent: UIViewController?) {
self.navigationController?.navigationBar.barTintColor = UIColor.red
Thanks to this approach you can set different navigation bar colors on different pages in the one Navigation Controller with smooth colors transitions between view in both ways - going to a child view and also coming back to parent.