Update the implementation `SDScaledImageForScaleFactor` to support SDAnimatedImage
This commit is contained in:
parent
08ca5f4b22
commit
2331bcc690
|
@ -9,6 +9,7 @@
|
|||
#import "SDWebImageDefine.h"
|
||||
#import "UIImage+Metadata.h"
|
||||
#import "NSImage+Compatibility.h"
|
||||
#import "SDAnimatedImage.h"
|
||||
#import "SDAssociatedObject.h"
|
||||
|
||||
#pragma mark - Image scale
|
||||
|
@ -81,6 +82,24 @@ inline UIImage * _Nullable SDScaledImageForScaleFactor(CGFloat scale, UIImage *
|
|||
return image;
|
||||
}
|
||||
UIImage *scaledImage;
|
||||
// Check SDAnimatedImage support for shortcut
|
||||
if ([image.class conformsToProtocol:@protocol(SDAnimatedImage)]) {
|
||||
if ([image respondsToSelector:@selector(animatedCoder)]) {
|
||||
id<SDAnimatedImageCoder> coder = [(id<SDAnimatedImage>)image animatedCoder];
|
||||
if (coder) {
|
||||
scaledImage = [[image.class alloc] initWithAnimatedCoder:coder scale:scale];
|
||||
}
|
||||
} else {
|
||||
// Some class impl does not support `animatedCoder`, keep for compatibility
|
||||
NSData *data = [(id<SDAnimatedImage>)image animatedImageData];
|
||||
if (data) {
|
||||
scaledImage = [[image.class alloc] initWithData:data scale:scale];
|
||||
}
|
||||
}
|
||||
if (scaledImage) {
|
||||
return scaledImage;
|
||||
}
|
||||
}
|
||||
if (image.sd_isAnimated) {
|
||||
UIImage *animatedImage;
|
||||
#if SD_UIKIT || SD_WATCH
|
||||
|
|
Loading…
Reference in New Issue