Fix the issue that SDAnimatedImage breaks the vector on macOS
This commit is contained in:
parent
b8523c1642
commit
e665fb52d6
|
@ -72,7 +72,7 @@
|
|||
|
||||
// This class override these methods from UIImage(NSImage), and it supports NSSecureCoding.
|
||||
// You should use these methods to create a new animated image. Use other methods just call super instead.
|
||||
// @note Before 5.19, these initializer will return nil for static image (when all candidate SDAnimatedImageCoder returns nil instance), like JPEG data. After 5.19, these initializer will retry for static image as well, so JPEG data will return non-nil instance.
|
||||
// @note Before 5.19, these initializer will return nil for static image (when all candidate SDAnimatedImageCoder returns nil instance), like JPEG data. After 5.19, these initializer will retry for static image as well, so JPEG data will return non-nil instance. For vector image(PDF/SVG), always return nil.
|
||||
// @note When the animated image frame count <= 1, all the `SDAnimatedImageProvider` protocol methods will return nil or 0 value, you'd better check the frame count before usage and keep fallback.
|
||||
+ (nullable instancetype)imageNamed:(nonnull NSString *)name; // Cache in memory, no Asset Catalog support
|
||||
#if __has_include(<UIKit/UITraitCollection.h>)
|
||||
|
|
|
@ -141,6 +141,12 @@ static CGFloat SDImageScaleFromPath(NSString *string) {
|
|||
if (!data || data.length == 0) {
|
||||
return nil;
|
||||
}
|
||||
// Vector image does not supported, guard firstly
|
||||
SDImageFormat format = [NSData sd_imageFormatForImageData:data];
|
||||
if (format == SDImageFormatSVG || format == SDImageFormatPDF) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
id<SDAnimatedImageCoder> animatedCoder = nil;
|
||||
SDImageCoderMutableOptions *mutableCoderOptions;
|
||||
if (options != nil) {
|
||||
|
@ -167,6 +173,10 @@ static CGFloat SDImageScaleFromPath(NSString *string) {
|
|||
if (!image) {
|
||||
return nil;
|
||||
}
|
||||
// Vector image does not supported, guard secondly
|
||||
if (image.sd_isVector) {
|
||||
return nil;
|
||||
}
|
||||
#if SD_MAC
|
||||
self = [super initWithCGImage:image.CGImage scale:MAX(scale, 1) orientation:kCGImagePropertyOrientationUp];
|
||||
#else
|
||||
|
|
Loading…
Reference in New Issue