Managing the Status Bar in iOS 7

One of the tenets of iOS 7’s new UI is full screen content.  To make full use of the screen, the OS now expects your app will extend underneath the Status Bar at the top of the screen.  Apple has created a new set of API’s to allow your apps to take advantage of this new feature.

First, gone are the old UIStatusBarStyleBlackOpaque and UIStatusBarStyleBlackTranslucent. These have been deprecated in favor of UIStatusBarStyleDefault and UIStatusBarStyleLightContent. If you have light background colors behind the Status Bar, use UIStatusBarStyleDefault and the system will use a black color for the time, carrier, and other elements in the Status Bar.

iOS 7 Status Bar

Similarly, if you have dark background colors, use UIStatusBarStyleLightContent for white colored Status Bar Elements.

iOS 7 Status Bar

You can use these new UIStatusBarStyle’s with the old methods on UIApplication:

[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;

However, there are also new methods on UIViewController which make status bar management much simpler.  Before you can manage Status Bar Style in UIViewController’s, you must first set UIViewControllerBasedStatusBarAppearance to YES in the application’s plist file.  This tells the OS to query the top level view controller for the Status Bar’s style, through the preferredStatusBarStyle method.  The implementation can be as simple as

- (UIStatusBarStyle) preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;

If your view controller changes such that you want the Status Bar Style to change, call the view controller’s setNeedsStatusBarAppearanceUpdate method. This tells the OS to call the view controller’s preferredStatusBarStyle method, where you can return a value based on the view controller’s changes.

It’s worth noting that the view controller’s preferred style can also be managed from nib and storyboard files.

iOS 7 Status Bar

Additional Reading

Mike Oliver has been a mobile junkie every since his first “Hello World” on a spinach-screened Blackberry. Lately, he works primarily with iOS, but he’s always looking for new ways to push the envelope from your pocket. Mike is currently the Lead iOS Engineer at RunKeeper, where he tries to make the world a healthier place one app at a time.