How to change Status Bar text color in iOS How to change Status Bar text color in iOS ios ios

How to change Status Bar text color in iOS


  1. Set the UIViewControllerBasedStatusBarAppearance to YES in the .plist file.

  2. In the viewDidLoad do a [self setNeedsStatusBarAppearanceUpdate];

  3. Add the following method:

    - (UIStatusBarStyle)preferredStatusBarStyle{     return UIStatusBarStyleLightContent; }

Note: This does not work for controllers inside UINavigationController, please see Tyson's comment below :)

Swift 3 - This will work controllers inside UINavigationController. Add this code inside your controller.

// Preferred status bar style lightContent to use on dark background.// Swift 3override var preferredStatusBarStyle: UIStatusBarStyle {    return .lightContent}

Swift 5 and SwiftUI

For SwiftUI create a new swift file called HostingController.swift

import Foundationimport UIKitimport SwiftUIclass HostingController: UIHostingController<ContentView> {    override var preferredStatusBarStyle: UIStatusBarStyle {        return .lightContent    }}

Then change the following lines of code in the SceneDelegate.swift

window.rootViewController = UIHostingController(rootView: ContentView())

to

window.rootViewController = HostingController(rootView: ContentView())


Alternatively, you can opt out of the view-controller based status bar appearance:

  1. Set View controller-based status bar appearance to NO in your Info.plist.
  2. Call [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

Note: This method has been deprecated in iOS9. Use preferredStatusBarStyle on the UIViewController instead. (see Apple Developer Library)


You can do this without writing any line of code!
Do the following to make the status bar text color white through the whole app

On you project plist file:

  • Status bar style: Transparent black style (alpha of 0.5)
  • View controller-based status bar appearance: NO
  • Status bar is initially hidden: NO