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 !

  • 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.

  • Feedback not found.

Add a Comment

Accepted Reply

this looks fixed in B3!

Thanks @Rincewind !

Add a Comment

Replies

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).

  • Hello Rincewind,

    Ive attached a sample project for feedback Feedback 9207440, it seems the navigation bar color clears also when popping back without changing any navigation bar appearance, its like it temporarily is cleared, then pops back in after animation is completed.

    Thanks!

  • Yea, looks like something is going wrong. We'll take a look.

  • Hi @Rincewind, this approach works fine for Xcode 13 and iOS 15, however it's broken for iOS 14. When changing the style of the navigation bar (or the navigation item), let's say from opaque to transparent when transitioning from VC A to B, the animation seems delayed during the push/pop. I'm making the change to the navigation item on view will appear (from both VC A and B). I tried "willMove(toParent)", "didMove(toParent)", "viewWillAppear", "viewDidLoad", etc. None of them seem to capture the right moment

Add a Comment

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
}
Post not yet marked as solved Up vote reply of paiv Down vote reply of paiv

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.

this looks fixed in B3!

Thanks @Rincewind !

Add a Comment

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
}

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.