45

I'm trying to convert my iOS 7 app to iOS 8 in Xcode 6 GM, and when i run it on the iPhone 5s or lower simulators with iOS 8 everything is fine, but on the iPhone 6 and 6 Plus simulators, the Status Bar has black text instead of white like it is everywhere anytime else. I've set the Info.plist UIStatusBarStyle to "Transparent Black Style (alpha of 0.5)" thru Xcode, and that seems to have the desired effect everywhere else. Any ideas what is going on?

(I haven't touched any of the storyboards yet, could it be anything with that? I was hoping I could put that off for a while:)

Krunal
  • 77,632
  • 48
  • 245
  • 261
Mohamed Hafez
  • 8,621
  • 7
  • 41
  • 49
  • 1
    So I've got the same issue, slightly different on two of my apps: On one app it starts off black during the splash screen and then changes to white once the UI loads, as I wish it to be. On iOS 7 it always launched fine in white. On another app it just stays black the whole time on iOS 8, or so I thought. Turns out that on an iPhone 5S running iOS 8 it's white, as it should be. And on a zoomed UI iPhone 6 it's fine, but not with the standard UI. The iPhone 6 Plus though is always black, regardless of the UI being zoomed or standard... Probably a bug in iOS 8 I guess... – CMash Sep 22 '14 at 13:15

14 Answers14

50

So here is how I fixed it

In PLIST View Controller Based Status Bar NO Status Bar Style UIStatusBarStyleLightContent

In AppDelegate DidFinishLaunching

[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
    [self.window setBackgroundColor:[UIColor whiteColor]];

In Each View Controller

- (UIStatusBarStyle) preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}
Dan
  • 9,391
  • 5
  • 41
  • 73
Taylor Pierce
  • 529
  • 3
  • 7
  • This answer is not really good. I've done exactly this and it does not help at all. This more looks like iPhone 6 bug. In addition to that, if you have View Controller Based Status Bar set to NO, what good does returning preferred status bar style in each view controller make? – Legoless Sep 24 '14 at 11:16
  • 6
    Worked for me but, there is no point in adding the preferredStatusBarStyle to each view controller if you specifically said in the info.plist that the property isn't view controller based. I also didn't need to set the window background color. – manecosta Jan 12 '15 at 17:00
  • 4
    Worked for me but only needed first line – josef Feb 09 '15 at 23:39
  • Needed the second line here (The Code in each view controller) – Omar Sultan Feb 14 '15 at 10:05
42

This bug only occurs if your app is being scaled to fit the resolution of the newer devices.

A quick fix (who knows whether this will even get addressed in 8.1) is to provide the proper resolution loading images in your app package.

From https://developer.apple.com/ios/human-interface-guidelines/graphics/launch-screen/

For iPhone 7, iPhone 6s, iPhone 6:

750 x 1334 (@2x) for portrait
1334 x 750 (@2x) for landscape

For iPhone 7 Plus, iPhone 6s Plus, iPhone 6 Plus:

1242 x 2208 (@3x) for portrait
2208 x 1242 (@3x) for landscape

In my app, we only support portrait, so providing the 750x1334 and 1242x2208 fixed it.

And just to confirm in case it wasn't obvious, you DO need to be using UIStatusBarStyleLightContent for your status bar style.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Aaron Wasserman
  • 1,249
  • 11
  • 8
  • 1
    I tried this solution, I'm still seeing the issue as @CMash described. – cthomaschase Sep 24 '14 at 22:07
  • EDIT: Not sure if the new launch images were being recognized, but this solution worked after I added them to the UILaunchImages section of the info.plist. – cthomaschase Sep 24 '14 at 22:36
  • 1
    Also you could use the new launch image nibs as I pointed out in my answer, that certainly clears up the issue! – CMash Oct 10 '14 at 13:32
  • 5
    Adding the proper resolution loading images will most likely require you to redesign your UI since it's no longer a 320x568 point coordinate system - unless you laid things out perfectly the first time around! For the rest of us who want their app scaled AND the UIStatusBarStyleLightContent style this won't do... – OpenUserX03 Oct 24 '14 at 06:53
  • @Aaron Wasserman , In my project i hide the status bar for whole app ,so i configure Info.plist(StatusBar Is Initially Hidden=YES & View-Controller Based...=NO).When I open the ImagePickerController from my app , status bar is show and then it does not hide.(Note : This issue is only on iPhone 6 & 6+ simulator,but not in iPhone 4 & 5).Thanks – Divyesh Dobariya Nov 04 '14 at 13:38
  • There is probably a reason why one is using the scaled version of the app on iPhone 6, so stop using it to fix a bug, isn't a great fix. – manecosta Jan 12 '15 at 17:02
16

My app's status bar was working fine in iOS 7 using only the project/target settings:

Status bar style = UIStatusBarStyleLightContent

and

View controller-based status bar appearance = NO

but in iOS 8 (iPhone 6 and iPhone 6 Plus simulators) the status bar was not showing up. Changing View controller-based status bar appearance to YES and then adding:

    // Objective C
    - (UIStatusBarStyle) preferredStatusBarStyle {
         return UIStatusBarStyleLightContent;
    }
    //Swift
    override func preferredStatusBarStyle() -> UIStatusBarStyle {
    return UIStatusBarStyle.LightContent
    }

to the ViewController resulted in seeing the white status bar again, but only after the initial root controller launches. During the initial launch the status bar remains black.

Tony Adams
  • 691
  • 1
  • 9
  • 29
  • I tried this on my app that launches black and then changes to white after the splash (worked fine on iOS 7) and it still launches in black to start with :( – CMash Sep 22 '14 at 13:18
  • It may also be restricted to iPhone 6 models too as some of the status bar colour issues I've seen don't happen on an iPhone 5S running iOS 8... – CMash Sep 22 '14 at 13:31
  • @CMash - yes - thanks. I'm seeing the same behavior. I'll edit the answer to clarify this. – Tony Adams Oct 08 '14 at 14:03
  • @Tony: Why "not swift version"? – lee Sep 15 '15 at 06:37
  • @lee - excellent question! I've edited the answer to include both. Thanks! – Tony Adams Sep 15 '15 at 13:13
15

A similar answer (currently voted as 2nd) has already posted, buy in the interests of keeping this post up-to-date, here is the Swift version.

  1. Add a row to your info.plist file called View controller-based status bar appearance and set its boolean value to NO.

  2. In your AppDelegate.swift file, add the following method: func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool { UIApplication.sharedApplication().statusBarStyle = .LightContent return true }

  3. I didn't need to do this step in order for it to work (i.e. do steps 1 and 2 and it might work). If not, try adding the following method to each of your ViewControllers:

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

I hope this was helpful,

Loic

Loic Verrall
  • 985
  • 15
  • 25
  • 1
    Very helpful! I only needed to do steps 1 & 2 as well – mbuff24 May 05 '15 at 15:23
  • Not sure, but I am experiencing this issue testing on actual iPhone 6/6Plus. Doesn't happen with the other models... very strange. I set the storyboard's status bar style to default and light content with no avail. This worked. – Alan Feb 11 '16 at 18:06
  • 1
    @Alan the storyboard's status bar style is actually just a visualisation in the storyboard - i.e. it has no affect on the status bar when the app is actually run. – Loic Verrall Feb 11 '16 at 18:21
  • 1
    I was having this same problem again with the iPad Pro, and since you can't upload a static launch image for the iPad Pro I couldn't use the first answer (and I can't use a storyboard launch file cuz I'm not using autolayout). Doing steps 1 & 2 here worked. Thanks! – Mohamed Hafez Feb 26 '16 at 00:50
7
  1. Open Info.plist
  2. Add new property called "View controller-based status bar appearance" (Boolean) and set its value to "NO"
  3. Add new property called "Status bar style" (String) and set its value to "Opaque black style"

Done.

José
  • 3,112
  • 1
  • 29
  • 42
6

Add the following line in AppDelegate's didFinishLaunchingWithOptions: method

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque animated:NO];
Raptor
  • 53,206
  • 45
  • 230
  • 366
Teja Kumar Bethina
  • 3,486
  • 26
  • 34
  • 1
    this worked for me, but UIStatusBarStyleBlackOpaque is deprecated, so i am using: [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:NO]; – Rosswerks Oct 10 '14 at 15:53
  • If your app supports all these iOS 6, 7 and 8 versions, then you should use 'UIStatusBarStyleBlackOpaque'. – Teja Kumar Bethina Oct 13 '14 at 05:12
  • The same worked for me. I didn't have to override preferredStatusBarStyle on every page – Oren Nov 21 '14 at 02:50
  • This works even without changing the launch image and messing up the point coordinate system – Stefan Arn Dec 02 '14 at 12:32
6

Step 1: Open the info.plist file of your app and set the UIViewControllerBasedStatusBarAppearance to NO

Step 2: info.plist file of your app and set the "Status bar style" to UIStatusBarStyleLightContent

Kakashi
  • 534
  • 11
  • 16
3

Could be problem with simulator. Use this to override default status bar or status bar for a specific view controller.

override func preferredStatusBarStyle() -> UIStatusBarStyle {
    return UIStatusBarStyle.LightContent
} //This is swift code
Saqib Omer
  • 5,387
  • 7
  • 50
  • 71
2

I know it's bad style to override behaviour in a base class using a category, but this works and may be the quickest solution to fix it.

Step #1: Ensure UIViewControllerBasedStatusBarAppearance or View controller-based status bar appearance is set to YES in your application plist file.

Step #2: Add the following code to your project:

@implementation UIViewController (StatusBarColorFix)

- (UIStatusBarStyle) preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}

@end
Sandy Chapman
  • 11,133
  • 3
  • 58
  • 67
1

A good fix for this is to use the new launch image nib support which gets used on the iPhone 6 models. It seems like there's just a bug in iOS 8 that means that the iPhone 6 models don't check the status bar style correctly when launching but it gets solved if you add in the launch nib.

As Aaron Wasserman pointed out you can also specify iPhone 6 & 6+ launch PNGs and that seems to fix the problem too, so long as you set them up right!

CMash
  • 1,987
  • 22
  • 35
1

Here is Apple Guidelines/Instruction about status bar/text color change.

Here is - How to change status bar style:

If you want to set status bar style, application level then set UIViewControllerBasedStatusBarAppearance to NO in your `.plist' file.

Or programatically you can do from App Delegate:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    application.statusBarStyle = .lightContent
    return true
}

if you wan to set status bar style, at view controller level then follow these steps:

  1. Set the UIViewControllerBasedStatusBarAppearance to YES in the .plist file, if you need to set status bar style at UIViewController level only.
  2. In the viewDidLoad add function - setNeedsStatusBarAppearanceUpdate

  3. override preferredStatusBarStyle in your view controller.

-

override func viewDidLoad() {
    super.viewDidLoad()
    self.setNeedsStatusBarAppearanceUpdate()
}

override var preferredStatusBarStyle: UIStatusBarStyle {
    return .lightContent
}

Set value of .plist according to status bar style setup level. enter image description here

Krunal
  • 77,632
  • 48
  • 245
  • 261
0

In your Storyboard select your root view controller and set status bar type default

Shafraz Buhary
  • 643
  • 6
  • 14
0

I have performed following steps and they worked for me quite well, should be working in iOS 8+ as well.

1) Added property View controller-based status bar appearance => NO in Info.plist.
2) Add following piece of code in - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions of AppDelegate.m

    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
    [self.window setBackgroundColor:[UIColor redColor]]; // Change color as per need.

3) Override method in ViewController

- (UIStatusBarStyle) preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}
Aamir
  • 16,329
  • 10
  • 59
  • 65
0

For swift 4 and iOS 11

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    application.statusBarStyle = .lightContent
    return true
}
eladHayun
  • 223
  • 4
  • 11