From 3e87488a4c292682d9dd95b43d8d93bd4bcc61d1 Mon Sep 17 00:00:00 2001 From: liulichao <1771617585@qq.com> Date: Sat, 9 May 2020 21:56:34 +0800 Subject: [PATCH] Modify SDAnimatedImageView --- SDWebImage/Core/SDAnimatedImageView.m | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/SDWebImage/Core/SDAnimatedImageView.m b/SDWebImage/Core/SDAnimatedImageView.m index 46d98d2b..e2bd432c 100644 --- a/SDWebImage/Core/SDAnimatedImageView.m +++ b/SDWebImage/Core/SDAnimatedImageView.m @@ -183,11 +183,8 @@ // Ensure disabled highlighting; it's not supported (see `-setHighlighted:`). super.highlighted = NO; - #if SD_UIKIT + [self stopAnimating]; - #else - [self setAnimates:NO]; - #endif [self checkPlay]; [self.imageViewLayer setNeedsDisplay]; @@ -328,6 +325,8 @@ } else { #if SD_UIKIT [super startAnimating]; +#else + [super setAnimates:YES]; #endif } } @@ -346,6 +345,8 @@ } else { #if SD_UIKIT [super stopAnimating]; +#else + [super setAnimates:NO]; #endif } } @@ -362,9 +363,17 @@ #endif #if SD_MAC +- (BOOL)animates +{ + if (self.player) { + return self.player.isPlaying; + } else { + return [super animates]; + } +} + - (void)setAnimates:(BOOL)animates { - [super setAnimates:animates]; if (animates) { [self startAnimating]; } else { @@ -392,19 +401,11 @@ { if (self.autoPlayAnimatedImage) { [self updateShouldAnimate]; - #if SD_UIKIT if (self.shouldAnimate) { [self startAnimating]; } else { [self stopAnimating]; } - #else - if (self.shouldAnimate) { - [self setAnimates:YES]; - } else { - [self setAnimates:NO]; - } - #endif } }