Skip to content

Instantly share code, notes, and snippets.

@Tricertops
Last active December 14, 2015 23:58
Show Gist options
  • Save Tricertops/5169153 to your computer and use it in GitHub Desktop.
Save Tricertops/5169153 to your computer and use it in GitHub Desktop.
The list of possible iOS resource suffixes sorted by their priority on different devices.

iPhone 5: -568h > ~iphone > @2x > .

-568h@2x~iphone
-568h~iphone
-568h@2x
-568h
@2x~iphone
~iphone
@2x
.

iPhone 4/4S: ~iphone > @2x > .

@2x~iphone
~iphone
@2x
.

iPhone 3GS: ~iphone > . > @2x

~iphone
@2x~iphone
.
@2x

iPad 3/4: ~ipad > @2x > .

@2x~ipad
~ipad
@2x
.

iPad 2/mini: ~iphone > . > @2x

~ipad
@2x~ipad
.
@2x
- (NSArray *)suffixesForThisDevice {
NSMutableArray *suffixes = [[NSMutableArray alloc] init];
NSArray *heights = ( UIDevice.iPhone && UIScreen.tall ? @[@"-568h",@""] : @[@""] );
NSArray *idioms = ( UIDevice.iPhone ? @[@"~iphone",@""] : @[@"~ipad",@""] );
NSArray *scales = ( UIScreen.retina ? @[@"@2x",@""] : @[@"",@"@2x"] );
for (NSString *height in heights) {
for (NSString *idiom in idioms) {
for (NSString *scale in scales) {
NSString *suffix = [NSString stringWithFormat:@"%@%@%@", height, scale, idiom];
[suffixes addObject:suffix];
}
}
}
return suffixes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment