Author Topic: How do I change the status bar content to white?  (Read 6353 times)

kjmcneish

  • Administrator
  • *****
  • Posts: 719
    • View Profile
How do I change the status bar content to white?
« on: October 06, 2013, 01:00:49 PM »
Here are the steps involved in changing the contents of the status bar (battery, time, signal) to white:

Starting with iOS 8, you need to set the status bar color in the Project Editor, otherwise the status bar flashes from black to white when your app first starts:
  • Select the very first node in the Project Navigator to display the Project Editor.
  • Select your app under Targets.
  • Select the General tab and under the Deployment Info section, set Status Bar Style to Light.

Next, you need to modify your project's .plist file.
  • In the Project Navigator, expand the Supporting Files node.
  • Select the <My Project Name>-Info.plist file.
  • Click on the very first entry (Information Property List).
  • Click the plus (+) sign that appears in the first column.
  • At the bottom of the popup list, select View controller-based status bar appearance.
  • Make sure the Value column is set to NO.
  • If you want to change the status bar content color for all scenes in your app, add the following code to the AppDelegate class's application:didFinishLaunchingWithOptions method (add it before the return YES statement), or you can add it to an individual view controller's viewDidLoad method:
In Swift:
Code: [Select]
UIApplication.sharedApplication().statusBarStyle = UIStatusBarStyle.LightContent
In Objective-C:
Code: [Select]
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
If you are hiding the status bar in some scenes in your app, and you have a root navigation controller, you may need to add the following code to the root navigation controller:

In Swift:
Code: [Select]
override func preferredStatusBarStyle() -> UIStatusBarStyle {
        return UIStatusBarStyle.LightContent
}

In Objective-C:
Code: [Select]
- (UIStatusBarStyle)preferredStatusBarStyle
{
    return UIStatusBarStyleLightContent;
}

All the best!
Kevin
Author of Learn to Code in Swift: https://itunes.apple.com/us/book/learn-to-code-in-swift/id942956811?mt=11
« Last Edit: July 14, 2015, 03:48:32 AM by kjmcneish »