I want to change the status bar style on a per-ViewController level on iOS 13. So far I didn't have any luck.
I define UIUserInterfaceStyle
as Light
in info.plist (as I do not want to support dark mode) and set UIViewControllerBasedStatusBarAppearance
to true
. preferredStatusBarStyle
is called on my ViewController but completely ignored. The UIUserInterfaceStyle
seems to always override the VC preferences.
How do I get per-ViewController status bar style working on iOS 13? Or is it not supported any more?

- 5,578
- 7
- 31
- 55
-
1It should work. The one from plist is used before the app is loaded (when splash screen is shown). The rest should be defined with `preferredStatusBarStyle` for each of the view controllers. Note that only top view controllers matter, not embedded ones. So it will work with controller you present but not with controller you for instance push on your navigation controller. To make navigation controller work as well you will need to subclass it forward the setting. – Matic Oblak Aug 22 '19 at 11:58
-
And this is without setting any option in the plist at all. These are default settings. – Matic Oblak Aug 22 '19 at 11:59
-
Is your `viewController` embedded inside `UINavigationController`? – Kamran Aug 22 '19 at 12:01
-
1Yes, it's in a TabBarController that holds NavigationBarControllers, but I already have extensions in place to deal with that. ```extension UITabBarController { open override var childForStatusBarStyle: UIViewController? { return selectedViewController?.childForStatusBarStyle ?? selectedViewController } } extension UINavigationController { open override var childForStatusBarStyle: UIViewController? { return topViewController?.childForStatusBarStyle ?? topViewController } }``` As I said, `preferredStatusBarStyle` is called but just ignored. – Micky Aug 22 '19 at 12:10
-
@MaticOblak did you test on iOS 13? Can you confirm it's working with the latest beta? – Micky Aug 22 '19 at 12:11
-
1@MaticOblak What compounds the problem is when you modal segue to a ViewController (or NavController) that's not full-screen, so is the modal cards UI of iOS 13 kick in. Now the status bar is owned by a view controller in Apple's control, so there's no way to subclass it! How can we control the status bar light/dark at that time? That ViewController tries to follow dark mode regardless of what I do. – Smartcat Sep 21 '19 at 02:07
-
1I am facing the same problem - Are you setting the window in the AppDelegate? I implemented a SceneDelegate and the statusbar now works as expected. The problem is this means I have a lot of `@available(iOS 13.0, *)` code and I have to implement the AppDelegate methods again. – DoesData Sep 26 '19 at 00:17
5 Answers
iOS 13.2, Swift 5.1
For me nothing worked from solutions mentioned before. After 5 hours I ended up on modalPresentationCapturesStatusBarAppearance flag .
destinationNavigationController.modalPresentationCapturesStatusBarAppearance = true
sourceViewController.present(destinationNavigationController, animated: animated, completion: nil)
After this preferredStatusBarStyle
was called in presented VC.
override var preferredStatusBarStyle: UIStatusBarStyle {
if #available(iOS 13.0, *) {
if traitCollection.userInterfaceStyle == .light {
return .darkContent
} else {
return .lightContent
}
} else {
return .lightContent
}
}

- 587
- 2
- 8
- 18
-
2`modalPresentationCapturesStatusBarAppearance = true` saved my day! – Peter Kreinz Dec 17 '19 at 17:43
-
@bezoadam i was trying same . But when my vc was present model. Still i was not able to see the status bar. After i dismiss that vc i can see black color status bar in my home screen.. – david Apr 24 '20 at 14:22
-
-
Nothing for me. In Info.plist I need something? I present overFullScreen. And I want the status bar always light (because I have a black View) Any suggestions? thanks – nonickname May 20 '20 at 09:45
-
you are genious modalPresentationCapturesStatusBarAppearance = true was a key in my issue too. In my case I set it up inside presented VC directly. – bojan Nov 11 '20 at 04:02
-
How do you fix this if you are trying to change the style of the Initial View controller of the App? The Main ViewController Gets presented automatically. `preferredStatusBarStyle ` never gets called here – João Eduardo Mar 31 '22 at 06:20
I had the same issue on iOS13 while it was fine on iOS12 for my app. I have a TabBarController which holds 3 NavigationBarControllers, and I present TabBarController from a previous ViewController. I fixed it by setting .modalPresentationStyle to .fullScreen when presenting:
tabbarController.modalPresentationStyle = .fullScreen
Maybe it will help you somehow...

- 131
- 1
- 8
In iOS13, there is now a .darkContent option for UIStatusBarStyle. For black text, use this (instead of .default) for preferredStatusBarStyle.

- 8,381
- 2
- 55
- 49
-
1This is what I needed to make the status bar correct in an app that doesn't support Dark Mode! – Rafael Nobre Mar 05 '20 at 17:41
In my case, I had a similar issue with incorrect UIStatusBarStyle
. For some view controllers in my app, I need to set a dark status bar style ignoring current system color mode. The problem was I used .default
value, but in iOS 13 it changes depending on the context. That's why I added a small workaround to handle both iOS 12- and iOS 13+ cases.
private extension UIStatusBarStyle {
static var darkContentWorkaround: UIStatusBarStyle {
if #available(iOS 13.0, *) {
return .darkContent
} else {
return .default
}
}
}

- 5,660
- 4
- 45
- 58
i had the same problem on iOS 13 while using navigation controller i was able to change the status bar color using
let navBarAppearance = UINavigationBarAppearance()
navigationBar.scrollEdgeAppearance = navBarAppearance
but the problem was when i was using present controller the status bar didn't change i used this code on top view controller
override func viewDidAppear(_ animated: Bool) {
if #available(iOS 13, *)
{
let statusBar = UIView(frame: (UIApplication.shared.keyWindow?.windowScene?.statusBarManager?.statusBarFrame)!)
statusBar.backgroundColor = UIColor.systemBackground
UIApplication.shared.keyWindow?.addSubview(statusBar)
}
}
you can use your color in "UIColor.systemBackground"

- 87
- 4
-
it's work, but now the color of status bar is diffirent from the navigation bar, only ios 12 have the same color, plz help – famfamfam Nov 04 '19 at 07:47
-
@famfamfam in ios13 apple changes how status bar color work,in ios13 what color you give to navigation bar the status bar pick that color.You can use below code to keep same Color. if #available(iOS 13.0, *) { let navBarAppearance = UINavigationBarAppearance() navBarAppearance.configureWithOpaqueBackground() navBarAppearance.backgroundColor = UIColor."YourColor" navBarAppearance.shadowColor = nil navigationBar.standardAppearance = navBarAppearance navigationBar.scrollEdgeAppearance = navBarAppearance } – Dante Nov 11 '19 at 08:45