1

In a child view controller, we are changing the navigation bar tint color on viewWillAppear, and then, to ensure the parent view controller's navigation bar tint color is restored, we set it's color on willMove in the child view controller.

  override func viewWillAppear(_ animated: Bool) {
    self.navigationController?.navigationBar.barTintColor = .black
  }

  override func willMove(toParentViewController parent: UIViewController?) {
    self.navigationController?.navigationBar.barTintColor = UIColor(red: 30, green: 30, blue: 30)
  }

The colors does not change correctly. This is the interaction:

  • Visit parent controller, color is correct gray
  • Visit child controller, (triggering viewWillAppear) color is the correct black
  • Go back to parent controller, (triggering willMove) color is a darker gray than intended

When you go back to the parent controller from the child controller, the color is lighter than the RGB value of what it is actually being set to.

The same RGB value is being set in the storyboard and displays on initial load of the parent view before the child view is visited.

enter image description here

Connorelsea
  • 2,308
  • 6
  • 26
  • 47
  • check this post http://stackoverflow.com/questions/39835420/navigationbar-delay-updating-bartintcolor-ios10/40255483#40255483 and i also recommend you to move your `willMove` code to `viewWillDisappear` and try? – Joe Dec 02 '16 at 22:38
  • If all your code is in a view controller, I'd put things in either viewWillAppear() or viewWillLayoutSubviews(), depending on your needs. Seems more of a proactive way to do things. –  Dec 03 '16 at 01:42

1 Answers1

0

If you are using Xcode 8 and iOS 10 the default color space should be sRGB when choosing your colors in the color picker.

See here for more information: Apple doc

Peter Warbo
  • 11,136
  • 14
  • 98
  • 193