Skip to content

Commit

Permalink
@3x support - replaced #1005
Browse files Browse the repository at this point in the history
  • Loading branch information
bpoplauschi committed Mar 19, 2015
1 parent 4f97897 commit 9620fff
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion SDWebImage/SDWebImageCompat.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,16 @@
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) {
CGFloat scale = 1.0;
if (key.length >= 8) {
// Search @2x. at the end of the string, before a 3 to 4 extension length (only if key len is 8 or more @2x. + 4 len ext)
// Search @2x. or @3x. at the end of the string, before a 3 to 4 extension length (only if key len is 8 or more @2x./@3x. + 4 len ext)
NSRange range = [key rangeOfString:@"@2x." options:0 range:NSMakeRange(key.length - 8, 5)];
if (range.location != NSNotFound) {
scale = 2.0;
}

range = [key rangeOfString:@"@3x." options:0 range:NSMakeRange(key.length - 8, 5)];
if (range.location != NSNotFound) {
scale = 3.0;
}
}

UIImage *scaledImage = [[UIImage alloc] initWithCGImage:image.CGImage scale:scale orientation:image.imageOrientation];
Expand Down

0 comments on commit 9620fff

Please sign in to comment.