iOS 15 broke the navigation appearance when navigating to a view controller with a transparent navigation bar from a non-transparent navigation bar

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?

Answered by Frameworks Engineer in 689734022

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.

The transition from secondVC to firstVC is smooth … but not from rootVC to firstVC

Could you detail what is wrong ?

It seems you have applied the solution described by Rincewind here: https://developer.apple.com/forums/thread/682420

Except you do not set appearance.backgroundColor in FirstVC.

Even though that does not explain why it's different from Second -> First than from Root -> First, could you try to add this in FirstVC:

appearance.backgroundColor = UIColor.clear
Accepted Answer

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.

iOS 15 broke the navigation appearance when navigating to a view controller with a transparent navigation bar from a non-transparent navigation bar
 
 
Q