My application is having default
status bar style for pre-login screens.
- After login, app uses lightContent
style for status bar throughout the app.
All was working fine till iOS 12. It started creating issue with iOS 13 (only when Dark Mode is enabled) .
Here are things which i have already tried, and still not getting things work fine.
- I did set
UIUserInterfaceStyle
toLight
- I did set
UIViewControllerBasedStatusBarAppearance
toYES
- Then I tried below code in individual view controller
override var preferredStatusBarStyle: UIStatusBarStyle { return .lightContent }
- Also added this line in
viewDidLoad()
of a class file.
setNeedsStatusBarAppearanceUpdate()
But still, I am not getting rid of this status bar related thing. I just simply need my status bar to be dark in screens before login, and once user logged in, it should the light.
Whole application should have identical UI for both dark and light modes. (as it is for OS below iOS 13) Which is working fine right now, but only status bar is changing colour.
Note: Everything is working fine when Dark Mode is disabled. This creating issues only when Dark Mode is enabled.
For my understanding, I created a new project in Xcode and added 3 screens with different status bar appearance.
A Working case
VC1 - Default
Style
VC2 - Default
Style
VC3 - LightContent
Style
A Working case
VC1 - LightContent
Style
VC2 - LightContent
Style
VC3 - Default
Style
Not Working (Failure) case
VC1 - Default
Style
VC2 - LightContent
Style
VC3 - Default
Style
What I assume is - if you use either of style in your application, it works fine regardless of Dark or Light mode of device. But if you combine Default
and LightContent
both for status bar appearance in your app, then it is not working as expected while dark mode is enabled.
Can any one please help me with this behaviour of Status Bar Style?
Here are my three view controller files. It simply pushes one controller to other one. It is files for the demo project which I have mentioned above. Which has the failure case.
When Dark Mode is OFF: I always get default
status bar style even when I override status bar style in VC2.
When Dark Mode is OFF: I always get lightContent
status bar style even when I override status bar style in VC1 & VC3.