How to pause a UIImageView animation

前端 未结 6 1733
有刺的猬
有刺的猬 2021-02-06 17:03

I have an animation that I\'m displaying using a UIImageView:

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


        
6条回答
  •  野性不改
    2021-02-06 17:50

    This code will pause an animated object at its current position in the animation process. If you record other variables like the time or progress or whatever you need, it should be fairly trivial to resume the animation again.

    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.
    

提交回复
热议问题