1

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

user3626411
  • 188
  • 2
  • 3
  • 15
  • This one might be helpful : https://stackoverflow.com/a/68600926/14733292 – Raja Kishan Aug 13 '21 at 14:37
  • Hi Raja, option with settings UIViewControllerBasedStatusBarAppearance to false and set UIStatusBarStyle for all viewcontrollers worked for me. If you write that as answer I will mark it as fix. Thanks – user3626411 Aug 16 '21 at 06:58

2 Answers2

1

In your UINavigationController override preferredStatusBarStyle and return .lightContent

class MyNavigationController: UINavigationController {
    override var preferredStatusBarStyle: UIStatusBarStyle {
        return .lightContent
    }
}
clawesome
  • 1,223
  • 1
  • 5
  • 10
  • This is awful... the status bar style color... I've been fighting with this issue for years, different rules based on plist, overrides, navigationVC, changing styles or overridding styles based in iOS version, or overriding the whole app? dark mode .... oh god, now i will attempt to have a class UINavigationControllerLight and UINavigationControllerDark... so much trouble just to pick a color... 1 or 0 it shouldn't be this complex – João Serra Mar 25 '22 at 17:51
1

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>
Raja Kishan
  • 16,767
  • 2
  • 26
  • 52