Merge pull request #3046 from dreampiggy/fix_ios14_vector_image_rendering

Fix the issue of iOS 14 vector image rendering on SDAnimatedImageView
This commit is contained in:
DreamPiggy 2020-07-01 22:42:52 +08:00 committed by GitHub
commit 4e2a52556c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 4 deletions

View File

@ -16,7 +16,10 @@
#import "SDInternalMacros.h"
#import "objc/runtime.h"
@interface SDAnimatedImageView () <CALayerDelegate> {
@interface UIImageView () <CALayerDelegate>
@end
@interface SDAnimatedImageView () {
BOOL _initFinished; // Extra flag to mark the `commonInit` is called
NSRunLoopMode _runLoopMode;
NSUInteger _maxBufferSize;
@ -466,12 +469,14 @@
- (void)displayLayer:(CALayer *)layer
{
UIImage *currentFrame = self.currentFrame;
if (!currentFrame) {
currentFrame = self.image;
}
if (currentFrame) {
layer.contentsScale = currentFrame.scale;
layer.contents = (__bridge id)currentFrame.CGImage;
} else {
// If we have no animation frames, call super implementation. iOS 14+ UIImageView use this delegate method for rendering.
if ([UIImageView instancesRespondToSelector:@selector(displayLayer:)]) {
[super displayLayer:layer];
}
}
}