Swift iOS 15: Status bar shows incorrect style when launching the app

Viewed 2529

My app uses a Navigation controller as the initial View Controller. Please see the screenshot attached

Main

In the first view controller, embedded in the navigation controller, I use the view did load method to set the navigation bar style as follows:

navigationController?.navigationBar.overrideUserInterfaceStyle = .dark
navigationController?.navigationBar.barStyle = .black
let appearance = UINavigationBarAppearance()
appearance.configureWithTransparentBackground()
navigationController?.navigationBar.standardAppearance = appearance
navigationController?.navigationBar.scrollEdgeAppearance = appearance 

The above 2 lines of codes, combined with the setting: View controller-based status bar appearance set to YES in the Info.plist allows me to successfully customize my status bar color as well as changing bar color when the user clicks on a specific button. Meaning that when the user clicks on a button on the same view controller, I can successfully change the status bar color settings to:

navigationController?.navigationBar.overrideUserInterfaceStyle = .light
navigationController?.navigationBar.barStyle = .default

Everything works as expected except when launching the app for the first time. When I kill the app and start it, the status bar color will be default instead of black. I have no idea why, it only happens when launching the app for the first time. Please see GIFs attached for example.

  • When starting the app, the status bar has a default style
  • When navigating away from the app, then back to it, the status bar has the correct style: .black

Im only facing this issue on the first screen of the app, the rest works just has expected. Wondering if anyone has an idea of whats going on here... Thanks in advance for your time!

Demo GIF

0 Answers
Related