From 61c3c5ba2d3c6b94e79fa4195fcccd9d5568db73 Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Mon, 19 Sep 2022 16:27:21 +0800 Subject: [PATCH] Fix the switching from animated image rendering to static image does not works on macOS 11+ We should always provide a fallback solution to handle built-in NSImageView logic --- SDWebImage/Core/SDAnimatedImageView.m | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/SDWebImage/Core/SDAnimatedImageView.m b/SDWebImage/Core/SDAnimatedImageView.m index 53d697f0..35260315 100644 --- a/SDWebImage/Core/SDAnimatedImageView.m +++ b/SDWebImage/Core/SDAnimatedImageView.m @@ -192,9 +192,8 @@ [self stopAnimating]; [self checkPlay]; - - [self.imageViewLayer setNeedsDisplay]; } + [self.imageViewLayer setNeedsDisplay]; } #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 ([UIImageView instancesRespondToSelector:@selector(displayLayer:)]) { [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; } } }