From ca6556b5f892eca720ece2b73fd5c46afd918d1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EA=B2=BD=EA=B5=AC?= Date: Fri, 23 Oct 2020 15:02:30 +0900 Subject: [PATCH] fix for ios 14 fix for support ios 14 --- YYImage/YYAnimatedImageView.m | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/YYImage/YYAnimatedImageView.m b/YYImage/YYAnimatedImageView.m index 5aa436f..f142b54 100644 --- a/YYImage/YYAnimatedImageView.m +++ b/YYImage/YYAnimatedImageView.m @@ -526,8 +526,16 @@ - (void)step:(CADisplayLink *)link { } - (void)displayLayer:(CALayer *)layer { - if (_curFrame) { - layer.contents = (__bridge id)_curFrame.CGImage; + //on iOS 13: If we override this, UIKit will render the UIImageView.image itself before calling this method. So even if self.currentFrame == nil, the UIImageView.image get rendered. + //on iOS 14: UIKit no longer render anything if you override that displayLayer: method. We can have a backup to render layer.contents for this case by ourself. + UIImage *currentFrame = _curFrame; + + if (currentFrame == nil) { + currentFrame = self.image; + } + + if (currentFrame) { + layer.contents = (__bridge id)currentFrame.CGImage; } }