IOS, Objective-c, Swift

How to change Status Bar text color in iOS

How to change Status Bar text color in iOS

The status bar can have a dark and light appearance inside an app In this tutorial the appearance of the status bar will be changed

  • Open Xcode and create a new Single View App.
  • For product name, use IOSColorStatusBarTutorial and then fill out the Organization Name and Organization Identifier with your customary values. Enter Swift as Language and choose Next.
  • Go to the Storyboard. Select the View and in the Attributes Inspector change the Background Color to Light Gray. Build and Run the Project. The default style of the status bar is dark content.

The style of the status bar can be changed to a status bar with white content. Go to the ViewController.swift file and add the following lines of code.

The preferredStatusBarStyle property is set to lightContent. Build and Run the project to see the content of the status bar changed to light.

Next, go back to the Storyboard, Select the View Controller and in the Editor menu Select Embed in Navigation Controller. Select the Navigation Bar and in the Attribute Inspector set the Bar Tint color to red. The Storyboard will look like this.

Build and Run the project, The content of the status bar is dark again, which is the default. The reason for this is, iOS asked for the style of the status bar of the navigation controller instead of the contained view controller.

To change the style of the navigation controller to lightinside the app, add the following viewDidAppear(_:) method

Build and Run the Project again, this time the content of the status bar changed to white.

There are Other options which we can try


Set the UIViewControllerBasedStatusBarAppearance to YES in the .plist file.

In the viewDidLoad do a [self setNeedsStatusBarAppearanceUpdate];

Add the following method:



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

Set View controller-based status bar appearance to NO in your Info.plist.

Call [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

Note: This method has been deprecated in iOS9. Use preferredStatusBarStyle on the UIViewController instead.

In AppDelegate add


In Info.plist, add a row:

Then in AppDelegate in didFinishLaunchingWithOptions, add these rows:


Under the Info tab of the project target, Add Row:


In the project AppDelegate.m:

Go to Project -> Target,

Then set Status Bar Style to Light. It makes status-bar white from the launch screen. Project Setting

Then set View controller-based status bar appearance equal to NO in Info.plist.

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

Swift 5 and SwiftUI

For SwiftUI create a new swift file called HostingController.swift

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