简体   繁体   中英

iPhone 6 Status bar color

Has anyone noticed that the Status bar color for the iPhone 6 simulator is not using the correct style?

I have UIStatusBarStyle set to UIStatusBarStyleLightContent and UIViewControllerBasedStatusBarAppearance set to NO .

This works fine for all phones on iOS8 except for 6 and 6 Plus. In my appDelegate I am able to set it using UIApplication.sharedApplication().setStatusBarStyle(.LightContent, animated: false) but this does not set it for the launch screen. It still wants dark when I would like light content. Does anyone have a fix for this. Is there a new item I need to add the the plist?

One option is to set UIViewControllerBasedStatusBarAppearance to YES in the plist, and then in each view controller have this method

- (UIStatusBarStyle) preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}

It is a pain in the ass to do and definitely not the nicest solution. As it stands, this works on all my view controllers but one, which I'm still looking for an alternative solution for this.

EDIT

Found a better solution. Keep UIViewControllerBasedStatusBarAppearance to NO and Status bar style to UIStatusBarStyleLightContent in the plist, then add the correct launch image by selecting + -> New Launch Image from the Image Assets. This will prevent iPhone 6/6+ from scaling the app up to the screen size and show the light status bar. The correct screen sizes are:

iPhone 4/4S: 640x960 px
iPhone 5/5S: 640x1136 px
iPhone 6:    750x1334 px (edited)
iPhone 6+:   1242x2208 px

I can't take credit for this, just testify that it worked. Here is where I found the solution https://stackoverflow.com/a/25985800/3247035 and http://beageek.biz/how-to-create-launch-images-app-xcode-ios/

i had the same problem and solved by

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setNeedsStatusBarAppearanceUpdate];
}

-(UIStatusBarStyle)preferredStatusBarStyle{
    return UIStatusBarStyleLightContent;
}

i'm lazy,so i created a controller to add it and all others inherit it

I also mentioned this in response to this post , but the only work around I've found is to convert your app to use the iPhone 6 and 6+ assets.

Once you provide correctly sized loading screen assets in your asset manager, your app will respect your status bar style settings.

From https://developer.apple.com/library/iOS/documentation/userexperience/conceptual/mobilehig/LaunchImages.html

For iPhone 6:

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

For iPhone 6 Plus:

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

You should also double check that you are setting your status bar style to UIStatusBarStyleLightContent. This can be done in two ways:

  • In your application's info.plist set UIStatusBarStyle = UIStatusBarStyleLightContent
  • Override the method preferredStatusBarStyle: in all applicable UIViewController's within your project. (For this option, make sure that in your application's info.plist you have UIViewControllerBasedStatusBarAppearance = YES)

pfryerda answer is correct with the launch image being the solution to the problem. I fixed my issue without even knowing. I used the new Launch Screen File section of the General Info tab and set my launch screen to be its own separate storyboard. In the storyboard I created a View that resized to full screen and I know longer have this issue since the launch screen is always the right size.

Just to recap on how to create a launch screen story board:

  1. Create a blank storyboard file named LaunchScreen.storyboard.

  2. Go to your target settings and, on the General tab, select the storyboard as your Launch Screen File. Xcode will add a corresponding UILaunchStoryboardName key to your appʼs Info.plist. When this key is present, Xcode will prioritize it over any launch images you might have set.

  3. Add a view controller scene to the storyboard. Add some subviews to the scene and position them with constraints. When you launch the app on a device, the OS should use the scene as the launch screen.

You can find out more here: http://oleb.net/blog/2014/08/replacing-launch-images-with-storyboards/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM