user3626411
user3626411

Reputation: 198

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

Upvotes: 1

Views: 1260

Answers (2)

Raja Kishan
Raja Kishan

Reputation: 19014

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>

Upvotes: 1

clawesome
clawesome

Reputation: 1319

In your UINavigationController override preferredStatusBarStyle and return .lightContent

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

Upvotes: 1

Related Questions