Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Status Bar showing black text, only on iPhone 6 iOS 8 simulator

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:)

like image 776
Mohamed Hafez Avatar asked Sep 16 '14 12:09

Mohamed Hafez


People also ask

What is iOS status bar?

A status bar appears along the upper edge of the screen and displays information about the device's current state, like the time, cellular carrier, and battery level.

What is preferredStatusBarStyle?

preferredStatusBarStyle (doc) - The preferred status bar style for the view controller. Subclass or extend UINavigationController class MyNavigationController: UINavigationController { override var preferredStatusBarStyle: UIStatusBarStyle { .lightContent } }


4 Answers

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;
}
like image 51
Taylor Pierce Avatar answered Oct 19 '22 02:10

Taylor Pierce


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.

like image 26
Aaron Wasserman Avatar answered Oct 19 '22 01:10

Aaron Wasserman


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.

like image 16
Tony Adams Avatar answered Oct 19 '22 02:10

Tony Adams


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

like image 15
Loic Verrall Avatar answered Oct 19 '22 02:10

Loic Verrall