How to change Status Bar text color in iOS

⋅ 2 min read ⋅ UIKit Status Bar

Table of Contents

By default, the color of a status bar text will change according to the device appearance setting. For example, the text will be black on light appearance and white text on dark appearance.

A status bar color can be white or black.
A status bar color can be white or black.

There are two ways to opt-out of this behavior and set the status bar text color yourselves.

  1. Change a status bar text color for an entire app.
  2. Change a status bar text color for specific view controller.

Change status bar text color for the Entire App using Info.plist

If you want to set the status bar text color for an entire app, you can do it by specifying two keys in Info.plist.

  1. "Status bar style" (UIStatusBarStyle)
  2. "View controller-based status bar appearance" (UIViewControllerBasedStatusBarAppearance)

Here are the steps to do it.

  1. Open your Info.plist, either from the Project Navigation or the "Info" tab.
Info.plist
Info.plist
  1. Add key "Status bar style" (UIStatusBarStyle) and set value to either "Light Content" (UIStatusBarStyleLightContent) or "Dark Content" (UIStatusBarStyleDarkContent).
  2. Add key "View controller-based status bar appearance" (UIViewControllerBasedStatusBarAppearance) and set its value to "NO".
Add two keys to Info.plist.
Add two keys to Info.plist.

You can easily support sarunw.com by checking out this sponsor.

Sponsor sarunw.com and reach thousands of iOS developers.

Change status bar text color for specific view controller

By default, the status bar text color will change according to active view controller.

A view controller communicates the preferred text color to the system via preferredStatusBarStyle property.

You can control the status bar text color by override preferredStatusBarStyle property in a view controller and return the style you want.

In this example, we set the status bar text color to white.

override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}

Read more article about UIKit, Status Bar, or see all available topic

Enjoy the read?

If you enjoy this article, you can subscribe to the weekly newsletter.
Every Friday, you'll get a quick recap of all articles and tips posted on this site. No strings attached. Unsubscribe anytime.

Feel free to follow me on Twitter and ask your questions related to this post. Thanks for reading and see you next time.

If you enjoy my writing, please check out my Patreon https://www.patreon.com/sarunw and become my supporter. Sharing the article is also greatly appreciated.

Become a patron Buy me a coffee Tweet Share
Previous
Create SwiftUI List from an Array

It is very common to populate a list view from an array of data. Let's learn how to do it in SwiftUI.

Next
Supporting SwiftUI List Selection

Learn how to add list row selection in SwiftUI List.

← Home