On iOS 15, when navigating to a view controller that has a transparent navigation bar, the navbar animation isn't working as expected.
It works as expected on iOS versions prior to 15. Please see attached video for iOS 14
Here's a video demonstration: https://www.dropbox.com/s/80d7qxzhql8fjj2/ios15%20transparent%20navbar%20delay.mov?dl=0
Demo project on Github: https://github.com/karlingen/NavigationTest
This is how I've set up my view controllers:
rootVC
let appearance = UINavigationBarAppearance()
appearance.configureWithDefaultBackground()
appearance.backgroundColor = UIColor.red
self.navigationController?.navigationBar.standardAppearance = appearance
self.navigationController?.navigationBar.scrollEdgeAppearance = self.navigationController?.navigationBar.standardAppearance
firstVC
let appearance = UINavigationBarAppearance()
appearance.configureWithTransparentBackground()
self.navigationController?.navigationBar.standardAppearance = appearance
self.navigationController?.navigationBar.scrollEdgeAppearance = self.navigationController?.navigationBar.standardAppearance
secondVC
let appearance = UINavigationBarAppearance()
appearance.configureWithDefaultBackground()
appearance.backgroundColor = UIColor.yellow
self.navigationController?.navigationBar.standardAppearance = appearance
self.navigationController?.navigationBar.scrollEdgeAppearance = self.navigationController?.navigationBar.standardAppearance
The transition from secondVC to firstVC is smooth (going from yellow to transparent) but not from rootVC to firstVC (going from red to transparent):
Has anyone found a workaround for this?
This is generally not a case that we optimize for since introducing per-item appearance customization in iOS 13 along with the UINavigationBarAppearance
API. If you want specific view controllers to have a different appearance, we recommend you customize the corresponding properties on UINavigationItem
rather than re-customizing your UINavigationBar
. This also enables you to do this customization early and without regard to precise timing, such as in viewDidLoad
which will always be called before your view controller is pushed onto the navigation stack.