YYImage icon indicating copy to clipboard operation
YYImage copied to clipboard

Notifies the animation end

Open animis93 opened this issue 6 years ago • 1 comments

Could you add a method to notify when the animation ends?

animis93 avatar Oct 01 '18 14:10 animis93

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
    }
}];

j796160836 avatar Oct 08 '18 09:10 j796160836