• Skip to main content
  • Skip to primary sidebar

Ravi Shankar

Tweaking Apps

  • Swift
  • Tech Tips
You are here: Home / ios / How to customize status bar in iOS

How to customize status bar in iOS

July 19, 2015 By Ravi Shankar 1 Comment

Status Bar appears at the top of your device displaying information such as battery left in your device and carrier details. The default style of status bar is black and looks as shown in the below screenshot.

But if your screen designs are dark then you can change the status bar style to Light Content. This can be done by adding an entry as part of info.plist file or by adding the required code in AppDelegate. And if you want to change status bar style for specific View Controllers then you can override the function preferredStatusBarStyle

Add entry to info.plist

Navigate to info.plist under SupportFiles folder and add a new entry “View controller-based status bar appearance” with value as NO.

This would prevent developers from changing the status bar style for specifc View Controlllers. Now you can speciy the preferred style by selecting the project target and choosing the value for Status Bar Style drop down under Deployment Info

Add code to AppDelegate

Instead of changing the option in Deployment Info, you can also do this through code by adding the following line inside AppDelegate’s didFinishLaunchingWithOptions method. Here we are changing the style to LightContent.

[code language=”swift”]UIApplication.sharedApplication().statusBarStyle = UIStatusBarStyle.LightContent[/code]

Customize style for specific ViewController

If you wish to apply the style for specific View Controllers then overiride the preferredStatusBarStyle function as shown below. This would work only if the entry “View controller-based status bar appearance” in info.plist file is not set NO

[code language=”swift”]override func preferredStatusBarStyle() -> UIStatusBarStyle {
return UIStatusBarStyle.LightContent
}[/code]

Filed Under: ios, Programming, Status Bar, Xcode Tagged With: Style

Reader Interactions

Comments

  1. Ganesh says

    January 17, 2018 at 6:28 am

    Superb explanation.

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

TwitterLinkedin

Recent Posts

  • How to block keywords in Jio broadband
  • How to disable opening an app automatically at login in Mac
  • How to set preferred Wifi network on Mac
  • Attribute Unavailable: Estimated section warning before iOS 11.0
  • How to recover Firefox password from Time Machine backup

Pages

  • About
  • Privacy Policy
  • Terms and Conditions

Copyright 2022 © rshankar.com

Terms and Conditions - Privacy Policy