Merge pull request #3402 from dreampiggy/fix_macOS_animatedview_render

Fix the switching from animated image rendering to static image does not works on macOS 11+
This commit is contained in:
DreamPiggy 2022-09-19 17:23:56 +08:00 committed by GitHub
commit 122c3d7ca5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -192,9 +192,8 @@
[self stopAnimating]; [self stopAnimating];
[self checkPlay]; [self checkPlay];
[self.imageViewLayer setNeedsDisplay];
} }
[self.imageViewLayer setNeedsDisplay];
} }
#pragma mark - Configuration #pragma mark - Configuration
@ -493,6 +492,11 @@
// If we have no animation frames, call super implementation. iOS 14+ UIImageView use this delegate method for rendering. // If we have no animation frames, call super implementation. iOS 14+ UIImageView use this delegate method for rendering.
if ([UIImageView instancesRespondToSelector:@selector(displayLayer:)]) { if ([UIImageView instancesRespondToSelector:@selector(displayLayer:)]) {
[super displayLayer:layer]; [super displayLayer:layer];
} else {
// Fallback to implements the static image rendering by ourselves (like macOS or before iOS 14)
currentFrame = super.image;
layer.contentsScale = currentFrame.scale;
layer.contents = (__bridge id)currentFrame.CGImage;
} }
} }
} }