iOS 15 B2 UINavigationBar Appearance color change delayed/Pop in when pushing a new viewcontroller

Hey All!

When transitioning my app to use the nav bar appearance (introduce in ios13, but required to make navigation bar colors / backgrounds in io15) i believe i had everything all changed over and working ! in iOS 15 b2 it seems when changing navbar backgrounds from view controller to view controller BEFORE the view is displayed in (viewwillload) there seems to be a delay in the change, aka until the animation finishes THEN the navbar background will change, which if you have 2 difference navbarbackgrounds expected for a different view looks less than ideal, as it seems like it "pops in" vs it being there as the animation happens in ios 15 b1 and ios 14 etc.

Any thoughts ? Thought maybe i was doing something wrong ! i submitted a feedback, but figured ide ask here too.

Thanks !

Answered by lmDeveloper1 in 681946022

this looks fixed in B3!

Thanks @Rincewind !

it also seems to be happening when "popping" back to a previous view controller via the "Back" button. the navbar appearance will be removed / empty until the animation completes. super weird.

If you are trying to make customizations for a specific view controller, we recommend you use the per-item support, by setting a configured appearance on the view controller's navigationItem.

Otherwise I would need to understand when you are trying to set things up. The navigation bar will not respond to changes while its animating, so if you are seeing popping its usually because your "late" when your changes (you set them after the animation began).

Stumbled on this issue myself, can confirm that it is different from how it was handled in iOS 14.

I've filed a feedback ticket FB9273852 with the project and video recording of the issue.

Stumbled on this issue myself, can confirm that it is different from how it was handled in iOS 14.

I've filed a feedback ticket FB9273852 with the project and video recording of the issue.

The code I'm using in the sample to set appearance of each child view controller:

override func viewDidLoad() {
    super.viewDidLoad()
    
    let barAppearance = UINavigationBarAppearance()
    barAppearance.backgroundColor = .green
    
    navigationItem.standardAppearance = barAppearance
    navigationItem.scrollEdgeAppearance = barAppearance
}

Please note that this is causing issues also if you have a controller with a large title and you push a controller that does not have a large title (navigationItem.largeTitleDisplayMode = .never).

In this case, during the transition, the top part of the pushed controller view is covered by the background color of the large navigation bar. When the transition ends, the top part suddenly become visible again (see below image).

I think that the problem is that during the transition the navigation bar height is not animated between the two states (the large title height and the compact height). On iOS 13 and iOS 14 there is a smooth animation between the two heights. I filled the bug report number FB9290717 and included a sample project that show this issue.

Accepted Answer

this looks fixed in B3!

Thanks @Rincewind !

I caught this bug in iOS 15(RC). Next code work for me.

override func viewDidLoad() {
    super.viewDidLoad()
    
    let barAppearance = UINavigationBarAppearance()
    barAppearance.backgroundColor = .white
    
    navigationBar.standardAppearance = barAppearance
    navigationBar.scrollEdgeAppearance = barAppearance
}

I confirm that IOS 15 and xcode 13.0

the problem is solved with:

if #available(iOS 13.0, *) {
            let barAppearance = UINavigationBarAppearance()
            barAppearance.backgroundColor = UIColor(named: "Arancione")!
            navigationController?.navigationBar.standardAppearance = barAppearance
            navigationController?.navigationBar.scrollEdgeAppearance = barAppearance
} else {
           // Fallback on earlier versions
}

Feedback not found.

I was able to fix the issue in Xcode 13 in the storyboard file by cycling the Top Bar property, of the navigation controller, to translucent navigation bar and then back to inferred.

iOS 15 B2 UINavigationBar Appearance color change delayed/Pop in when pushing a new viewcontroller
 
 
Q