How to change status bar style during launch on iOS 7

IosObjective CIos7

Ios Problem Overview


When I launch my app, it shows the launch image and a black status bar. How can I change it so the status bar is light during launch? I have set the status bar appearance to light in my AppDelegate didFinishLoading method, and it works for the rest of the app.

Ios Solutions


Solution 1 - Ios

To your Info.plist file add this key-value pair:

UIStatusBarStyle: UIStatusBarStyleLightContent

The default (black) value is UIStatusBarStyleDefault.

You can also append ~iphone or ~ipad to the key.

Solution 2 - Ios

There are 2 steps:

  1. This is usually what developers know how to do – Under Target settings > General > Status Bar Style > Change to Light. This will effect the Info.plist to include UIStatusBarStyleLightContent.

  2. This step is often missed out – In Info.plist, add View controller-based status bar appearance and set to NO

Solution 3 - Ios

Just define this method in any view or file you want:

- (UIStatusBarStyle)preferredStatusBarStyle
{
    return UIStatusBarStyleLightContent;
}

// swift 
override func preferredStatusBarStyle() -> UIStatusBarStyle {
    return .LightContent
}

Solution 4 - Ios

In my case, UIStatusBarStyleLightContent wasn't a possible option. I set Transparent black style (alpha of 0.5) as value for the key Status bar style in my .plist and the result was a white status bar.

Solution 5 - Ios

Works on iOS7 and iOS8

You need to set in your Info.plist file property for key Status bar style:

  1. Set Opaque black style or Transparent black style (alpha of 0.5) for White status bar
  2. Set Gray style (default) to set Black status bar color.

It looks like you set Background style for Status Bar and XCode understand which color of status bar need to choose. Dark background - white status bar, light background - black status bar

Solution 6 - Ios

**

 - You must take care of these three things:

**

**- In info.plist file**
Set UIViewControllerBasedStatusBarAppearance to YES

**- In your view controller** in which you want change color of status bar
add this [self setNeedsStatusBarAppearanceUpdate] in viewDidLoad

**- Lastly, add this method**
- (UIStatusBarStyle)preferredStatusBarStyle
{
      return UIStatusBarStyleLightContent;
}

Note: If you want to set color of statusBar for all the View Controllers then steps are
**- In info.plist file**
Set UIViewControllerBasedStatusBarAppearance to YES

**- Then add this in appDelegate**
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent; // **It is deprecated in iOS 9**

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser1008096View Question on Stackoverflow
Solution 1 - IosTricertopsView Answer on Stackoverflow
Solution 2 - IossamwizeView Answer on Stackoverflow
Solution 3 - IosMohit TomarView Answer on Stackoverflow
Solution 4 - IosBalestraPatrickView Answer on Stackoverflow
Solution 5 - IosPavel VolobuevView Answer on Stackoverflow
Solution 6 - IosrahulchonaView Answer on Stackoverflow