swiftuinavigationbaruistatusbarios15

iOS15 UINavigationBarAppearance hide battery / time icons (UIStatusBarStyle)


On iOS15 I was no longer able to set as black

UINavigationBar.appearance().tintColor = .white
UINavigationBar.appearance().barTintColor = UIColor(hexString: "#000000")
UINavigationBar.appearance().barStyle = UIBarStyle.black

I've fixed that with change

let appearance = UINavigationBarAppearance()
appearance.configureWithTransparentBackground()
appearance.backgroundColor = .black
appearance.titleTextAttributes = [.foregroundColor: UIColor.white]
appearance.largeTitleTextAttributes = [.foregroundColor: UIColor.white]

UINavigationBar.appearance().standardAppearance = appearance;
UINavigationBar.appearance().scrollEdgeAppearance = UINavigationBar.appearance().standardAppearance;

but now I have a problem with missing battery / clock icons

Not working iOS15

Working iOS13


Solution

  • Change status bar style from the info.plist

    1: Set UIViewControllerBasedStatusBarAppearance to false

    <key>UIViewControllerBasedStatusBarAppearance</key>
        <false/>
    

    2: Add Status bar style key and set style like Light Content

    <key>UIStatusBarStyle</key>
    <string>UIStatusBarStyleLightContent</string>