Mastering iOS 7 UIStatusBarStyle
iOS 7 introduces the UIViewControllerBasedStatusBarAppearance
plist setting allowing us to change the statusBar’s text color when the main viewController changes.
Getting it to work can feel tricky however.
- Ensure you set
UIViewControllerBasedStatusBarAppearance
to booleanYES
in your plist. - Ensure you set still set the default statusBar style in your plist, this will show during the splash screen.
- Override
preferredStatusBarStyle
providing your viewController is not inside aUINavigationController
. - If your viewController is inside a navigationController then preferredStatusBarStyle seems to be ignored completely. Instead the navigationController’s navigationBar’s
barStyle
is used. A Dark barStyle makes the statusBar white, the default barStyle makes the statusBar text black.
This in fact makes some sense. The application queries the main viewController’s preferredStatusBar style, so if you have a navigationController the main viewController is the navigationController.
Written by Max Howell
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Iphone
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#