Open animis93 opened 6 years ago
You can use KVO for the currentAnimatedImageIndex
and check it with animatedImageFrameCount
.
Here is the sample code with KVOController:
__weak typeof(self) weakSelf = self;
[self.KVOController observe:self.myYYAnimatedImageView keyPath:@"currentAnimatedImageIndex" options:NSKeyValueObservingOptionInitial|NSKeyValueObservingOptionNew block:^(id _Nullable observer, YYAnimatedImageView *imageView, NSDictionary *change) {
YYImage *image = (YYImage *) imageView.image;
NSInteger frameNum = [change[@"new"] integerValue];
if (frameNum == image.animatedImageFrameCount - 1) {
[weakSelf.KVOController unobserve:imageView];
// Do something you want with myYYAnimatedImageView
}
}];
Could you add a method to notify when the animation ends?