Skip to content

Instantly share code, notes, and snippets.

Last active March 20, 2019 14:20
What would you like to do?
About iOS 7 Status Bar Style

UIStatusBarStyle in iOS 7

  • The status bar in iOS 7 is transparent, the view behind it shows through.

  • The style of the status bar refers to the appearances of its content. In iOS 7, the status bar content is either dark (UIStatusBarStyleDefault) or light (UIStatusBarStyleLightContent). Both UIStatusBarStyleBlackTranslucent and UIStatusBarStyleBlackOpaque are deprecated in iOS 7.0. Use UIStatusBarStyleLightContent instead.

How to change UIStatusBarStyle

  • If below the status bar is a navigation bar, the status bar style will be adjusted to match the navigation bar style (UINavigationBar.barStyle):

    Specifically, if the navigation bar style is UIBarStyleDefault, the status bar style will be UIStatusBarStyleDefault; if the navigation bar style is UIBarStyleBlack, the status bar style will be UIStatusBarStyleLightContent.

  • If there is no navigation bar below the status bar, the status bar style can be controlled and changed by an individual view controller while the app runs.

    -[UIViewController preferredStatusBarStyle] is a new method added in iOS 7. It can be overridden to return the preferred status bar style:

      - (UIStatusBarStyle)preferredStatusBarStyle
      	return UIStatusBarStyleLightContent;
  • If the status bar style should be controlled by a child view controller instead of self, override -[UIViewController childViewControllerForStatusBarStyle] to return that child view controller.

  • If you prefer to opt out of this behavior and set the status bar style by using the -[UIApplication statusBarStyle] method, add the UIViewControllerBasedStatusBarAppearance key to an app’s Info.plist file and give it the value NO.

Copy link

This is one of the best explanations how the new status bar works. A textbook example how Apple documentation should look like.

Copy link

barbaramartina commented Sep 27, 2016

Thanks for the great short effective guide!. I'd like only to add that in the case in which your view controller wants to change the bar style depending on some conditions, you need to call (Swift 2.3):


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment