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 P
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
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
For swift 4 and iOS 11
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
application.statusBarStyle = .lightContent
return true
}
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.
Add a row to your info.plist file called View controller-based status bar appearance and set its boolean value to NO.
In your AppDelegate.swift file, add the following method:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {
UIApplication.sharedApplication().statusBarStyle = .LightContent
return true
}
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
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
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.