How to pause UIImageView animation

I have an animation that I am showing with UIImageView:

imageView.animationImages = myImages;
imageView.animationDuration = 3;
[imageView startAnimating];

I know I can stop him using stopAnimating, but I want him to be able to pause him. The reason is that when you call a stop, none of your animated images are displayed, whereas I would like the latter to be at the time I pressed the button so as not to sleep.

I tried to set the duration to a much larger number, but this also leads to the disappearance of all images. Should there be a really easy way to do this?

+3
source share
6 answers

Hmmm ... since no one seems to know, I think this is impossible.

UIView, UIImageView subview, NSTimer . , , .

+8

. , , , , .

UIView *viewBeingAnimated = //your view that is being animated
viewBeingAnimated.frame = [[viewBeingAnimated.layer presentationLayer] frame];
[viewBeingAnimated.layer removeAllAnimations];
//when user unpauses, create new animation from current position.
+18

@oddmeter :

    animatedView.animationImages = images; //images is your array
    [animatedView startAnimating];


    //Then when you need to pause;

[animatedView stopAnimating]; //Important!!
    animatedView.image = [images objectAtIndex: 0];
+3

- , animationImages. UIImageView.

, UIImageView NSMutableArray , :

self.animationImages = images;
//yes, I'm skipping the step to check and make sure you have at least one
//element in your array
self.image = [images objectAtIndex: 0];
0

, ?

-1

Source: https://habr.com/ru/post/1698964/


All Articles