iOS Swift 4 Coding

How change statusbar background color and text color in Xcode using storyboard?

4 views September 22, 2018 September 21, 2018 bicobro 0

If you want to change the status bar background color and text color you have to perform several steps. In this example we want light text on a dark background.

Change the statusbar text color to white

To change the text color, perform the following steps (not needed when the color of the text must be black):

  1. Open your storyboard file
  2. Go to the main navigation controller
  3. Create a ViewController swift file for it if not available
  4. Add the following code to it to show white text:
override var preferredStatusBarStyle: UIStatusBarStyle {
    return .lightContent

Change the statusbar background color

To change the background color of the status bar:

  1. Open the AppDelegate.swift file and add:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.
    let statusBar: UIView = UIApplication.shared.value(forKey: "statusBar") as! UIView
    if statusBar.responds(to: #selector(setter: UIView.backgroundColor)) {
        statusBar.backgroundColor =
    return true

2. Open the info.plist as Source Code and add:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">

Was this helpful?