Changing the Color of the Status Bar

Tyler Rutt picture Tyler Rutt · Mar 28, 2017 · Viewed 14.8k times · Source

I am trying to change the color of the status bar to like a blue, or some other color.

Is this possible, or does Apple not allow it?

Answer

user3182143 picture user3182143 · Mar 28, 2017

NOTE: This solution fails under iOS 13 and later.

First in Plist set View controller-based status bar appearance to NO

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 = UIColor.blue
    }
    UIApplication.shared.statusBarStyle = .lightContent

    return true
}

The output screenshot is below

enter image description here