iOS version specific info.plist settings

2019-02-15 06:09发布

I am in the process of updating an app for iOS7 (while still supporting iOS6), and have updated the status bar to use a white foreground using UIStatusBarStyle: UIStatusBarStyleLightContent.

However the UIStatusBarStyleLightContent value is new in iOS7, and so when run on iOS6 the UIStatusBarStyle reverts back to UIStatusBarStyleDefault, giving the light-gray with dark text iOS6 default. But I need my iOS6 version to use the black style UIStatusBarStyleBlackOpaque status bar.

Given you can set info.plist settings for different device and platform types, e.g. UIStatusBarStyle~ipad: https://developer.apple.com/library/ios/DOCUMENTATION/iPhone/conceptual/iPhoneOSProgrammingGuide/AdvancedAppTricks/AdvancedAppTricks.html

I know I can set the value at runtime via the UIApplication, but this doesn't have an affect until after the startup image has displayed.

I am hoping you can use a similar mechanism for iOS versions? e.g:

UIStatusBarStyle: UIStatusBarStyleBlackOpaque
UIStatusBarStyle~ios7: UIStatusBarStyleLightContent

However that doesn't work and I can't find any apple documentation anywhere on such a feature. Am I out of luck and will have to live with the ugly white status bar during iOS6 app launches?

EDIT: Just found a similar question here: iOS - Entry in Info.plist for only iOS 6 and above?

Seems like the answer is no, this is not possible. Unless there have been any updates with iOS7?

1条回答
Bombasti
2楼-- · 2019-02-15 06:48

Use this, As i think so, this will be helpful to you,

if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {
    // Load resources for iOS 6.1 or earlier, i.e set status bar here for previous versions 
} else {
    // Load resources for iOS 7 or later, set status bar here for ios 7 
}
查看更多
登录 后发表回答