Home > front end >  Making status bar opaque on iOS >= 15
Making status bar opaque on iOS >= 15

Time:03-03

So, as from iOS 15, its updated how navigation bar looks. If there is no content behind it (eg. we didn't scroll up), it will be transparent. Now this affects status bar as well.

When I hide navigation bar, status bar stays transparent. If I do this (app delegate):

 if #available(iOS 15.0, *) { 
        let navigationBarAppearance = UINavigationBarAppearance() 
        navigationBarAppearance.configureWithOpaqueBackground() 
        navigationBarAppearance.backgroundColor = .systemPurple
        UINavigationBar.appearance().standardAppearance = navigationBarAppearance 
        UINavigationBar.appearance().compactAppearance = navigationBarAppearance 
        UINavigationBar.appearance().scrollEdgeAppearance = navigationBarAppearance 
    }

This will work only if my navigation bar is not hidden. Otherwise, if I do in view controller something like this:

navigationController.isNavigationBarHidden = true

my status bar stays transparent.

Which is not biggie. I will just use safe area, and set background color of view controllers view, and it will look like status bar actually has a color. But it still transparent. Even if I have done navigationBarAppearance.configureWithOpaqueBackground()

Am I missing something, its impossible to make status bar opaque (and colorized) while navigation controller is hidden (not visible) on iOS >= 15?

CodePudding user response:

its impossible to make status bar opaque (and colorized) while navigation controller is hidden (not visible) on iOS >= 15?

This has nothing to do with iOS 15. There is nothing new in iOS 15 affecting the status bar. The status bar has been transparent for something like 6 or 7 years now. (I don't have time to figure out when this change happened; the point is, it's ancient history.) There is no such thing as an opaque and/or colorized status bar, and there hasn't been for all that time. The navigation bar transparency / opacity does not affect the status bar transparency in any way. If the status bar shows the navigation bar behind it, fine; you seem to like that. If you don't like the color of what's behind the status bar when the navigation bar is hidden or transparent, change whatever's visible behind the status bar.

  • Related