@3x support - replaced #1005
This commit is contained in:
parent
4f97897a41
commit
9620fffa64
|
@ -30,11 +30,16 @@ inline UIImage *SDScaledImageForKey(NSString *key, UIImage *image) {
|
||||||
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) {
|
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) {
|
||||||
CGFloat scale = 1.0;
|
CGFloat scale = 1.0;
|
||||||
if (key.length >= 8) {
|
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)];
|
NSRange range = [key rangeOfString:@"@2x." options:0 range:NSMakeRange(key.length - 8, 5)];
|
||||||
if (range.location != NSNotFound) {
|
if (range.location != NSNotFound) {
|
||||||
scale = 2.0;
|
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];
|
UIImage *scaledImage = [[UIImage alloc] initWithCGImage:image.CGImage scale:scale orientation:image.imageOrientation];
|
||||||
|
|
Loading…
Reference in New Issue