iOS15 UINavigationBarAppearance hide battery / time icons (UIStatusBarStyle)

1.2k Views Asked by At

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

2

There are 2 best solutions below

0
Raja Kishan On BEST ANSWER

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>
1
clawesome On

In your UINavigationController override preferredStatusBarStyle and return .lightContent

class MyNavigationController: UINavigationController {
    override var preferredStatusBarStyle: UIStatusBarStyle {
        return .lightContent
    }
}