Skip to content

Commit da99ffa

Browse files
author
Jim Puls
committed
Merge pull request #1 from ios/natan/tall-phone-support
Add support for retina4 subtype assets
2 parents baf51a7 + 6b17b0b commit da99ffa

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

assetgen/AGCatalogParser.m

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ - (void)parseImageSetAtURL:(NSURL *)url;
7979
NSArray *variants = [contents[@"images"] sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
8080
if (![obj1[@"subtype"] isEqualToString:obj2[@"subtype"]]) {
8181
if (obj1[@"subtype"]) {
82-
return NSOrderedAscending;
82+
return NSOrderedDescending;
8383
}
8484
if (obj2[@"subtype"]) {
85-
return NSOrderedDescending;
85+
return NSOrderedAscending;
8686
}
8787
}
8888

@@ -127,15 +127,17 @@ - (void)parseImageSetAtURL:(NSURL *)url;
127127
continue;
128128
}
129129
BOOL isUniversal = [variant[@"idiom"] isEqualToString:@"universal"];
130+
BOOL isRetina4Inch = [variant[@"subtype"] isEqualToString:@"retina4"];
130131
NSString *indentation = @"";
131132
if (!isUniversal) {
132133
NSString *idiom = [variant[@"idiom"] isEqualToString:@"iphone"] ? @"UIUserInterfaceIdiomPhone" : @"UIUserInterfaceIdiomPad";
133-
[implementation appendFormat:@" if (UI_USER_INTERFACE_IDIOM() == %@) {\n", idiom];
134+
[implementation appendFormat:@" if (UI_USER_INTERFACE_IDIOM() == %@%@) {\n", idiom, isRetina4Inch ? @" && [UIScreen mainScreen].bounds.size.height == 568.0f" : @""];
134135
indentation = @" ";
135136
}
136137

137138
CGFloat scale = [variant[@"scale"] floatValue];
138-
NSString *filename = [variant[@"filename"] stringByReplacingOccurrencesOfString:[NSString stringWithFormat:@"@%@", variant[@"scale"]] withString:@""];
139+
NSString *sizeExtension = isRetina4Inch ? @"-568h" : @"";
140+
NSString *filename = [variant[@"filename"] stringByReplacingOccurrencesOfString:[NSString stringWithFormat:@"@%@", variant[@"scale"]] withString:sizeExtension];
139141
NSString *scaleIndentation = [indentation stringByAppendingString:@" "];
140142
[implementation appendFormat:@"%@if ([UIScreen mainScreen].scale == %.1ff) {\n", scaleIndentation, scale];
141143
[implementation appendFormat:@"%@ image = [UIImage imageNamed:@\"%@\"];\n", scaleIndentation, filename];

0 commit comments

Comments
 (0)