Modify SDAnimatedImageView

This commit is contained in:
liulichao 2020-05-09 21:56:34 +08:00
parent e7386083f7
commit 3e87488a4c
1 changed files with 14 additions and 13 deletions

View File

@ -183,11 +183,8 @@
// Ensure disabled highlighting; it's not supported (see `-setHighlighted:`). // Ensure disabled highlighting; it's not supported (see `-setHighlighted:`).
super.highlighted = NO; super.highlighted = NO;
#if SD_UIKIT
[self stopAnimating]; [self stopAnimating];
#else
[self setAnimates:NO];
#endif
[self checkPlay]; [self checkPlay];
[self.imageViewLayer setNeedsDisplay]; [self.imageViewLayer setNeedsDisplay];
@ -328,6 +325,8 @@
} else { } else {
#if SD_UIKIT #if SD_UIKIT
[super startAnimating]; [super startAnimating];
#else
[super setAnimates:YES];
#endif #endif
} }
} }
@ -346,6 +345,8 @@
} else { } else {
#if SD_UIKIT #if SD_UIKIT
[super stopAnimating]; [super stopAnimating];
#else
[super setAnimates:NO];
#endif #endif
} }
} }
@ -362,9 +363,17 @@
#endif #endif
#if SD_MAC #if SD_MAC
- (BOOL)animates
{
if (self.player) {
return self.player.isPlaying;
} else {
return [super animates];
}
}
- (void)setAnimates:(BOOL)animates - (void)setAnimates:(BOOL)animates
{ {
[super setAnimates:animates];
if (animates) { if (animates) {
[self startAnimating]; [self startAnimating];
} else { } else {
@ -392,19 +401,11 @@
{ {
if (self.autoPlayAnimatedImage) { if (self.autoPlayAnimatedImage) {
[self updateShouldAnimate]; [self updateShouldAnimate];
#if SD_UIKIT
if (self.shouldAnimate) { if (self.shouldAnimate) {
[self startAnimating]; [self startAnimating];
} else { } else {
[self stopAnimating]; [self stopAnimating];
} }
#else
if (self.shouldAnimate) {
[self setAnimates:YES];
} else {
[self setAnimates:NO];
}
#endif
} }
} }