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.
willMove
code toviewWillDisappear
and try? – Joe