Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Making status bar opaque on iOS >= 15

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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?

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading