I have FirstViewControllerand a SecondViewController. They have different colors for their own UINavigationBar. When I show SecondViewController, the color gradually fades. I recorded an animation with a simulator and slow animations.

However, when I return from SecondViewControllerto FirstViewController, the color is not animated , and everything changes immediately.

This is how I set the code for UINavigationBarin SecondViewController.
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if let navBar = self.navigationController?.navigationBar {
navBar.barStyle = UIBarStyle.black
navBar.barTintColor = NavBarColor.red
navBar.backgroundColor = NavBarColor.red
navBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.white]
navBar.isTranslucent = false
navBar.tintColor = .white
}
}
In my class, FirstViewControllerI created a structure NavBarSettingsand saved information about the UINavigationBar. Then I apply them in viewWillAppear.
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if let navBar = self.navigationController?.navigationBar,
let navBarSettings = self.navBarSettings {
navBar.barStyle = navBarSettings.barStyle
navBar.barTintColor = navBarSettings.barTintColor
navBar.backgroundColor = navBarSettings.backgroundColor
navBar.titleTextAttributes = navBarSettings.titleTextAttributes
navBar.isTranslucent = navBarSettings.isTranslucent
navBar.tintColor = navBarSettings.tintColor
}
}
I also tried changing the UINavigationBar's information SecondViewController viewWillDisappear, but it had the same effect.
backgroundColor, .
?
SecondViewController .
self.performSegue(withIdentifier: "SecondViewControllerSegue", sender: nil)
- , UINavigationController.