Phong Le
Phong Le

Reputation: 281

How do I conditionally load assets for iOS7 and iOS6?

So I was reading the transitioning guide that I can conditionally load assets for either iOS6 or iOS7 if I'm using storyboard. I am using it, but I don't understand how I load assets into a story board.

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

Upvotes: 0

Views: 429

Answers (1)

WrightsCS
WrightsCS

Reputation: 50707

You can use these:

/** 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

You can also use it like this:

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

Upvotes: 1

Related Questions