如何为iOS 7和iOS 6有条件地加载资源?

时间:2013-09-24 20:07:24

标签: iphone ios6 storyboard ios7 xcode5

所以我正在阅读过渡指南,如果我使用的是故事板,我可以有条件地为iOS6或iOS7加载资源。我正在使用它,但我不明白如何将资源加载到故事板中。

https://developer.apple.com/library/ios/documentation/userexperience/conceptual/TransitionGuide/SupportingEarlieriOS.html

1 个答案:

答案 0 :(得分:1)

你可以使用这些:

/** iOS Version Comparisons */
#define SYSTEM_VERSION_EQUAL_TO(v)                  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v)              ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v)                 ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v)     ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)


if ( SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0") ) 
    // do something for iOS 7
else
    // do something for iOS 6, 5, 4

你也可以这样使用它:

[myButton setBackgroundImage:( SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0") ? @"image_ios7" : @"image_ios6" )];