How to pause and resume UIView Animation?

后端 未结 5 1377
长发绾君心
长发绾君心 2020-12-10 08:28

I have a UIView with several UILabels that is animating from top to bottom and vice versa. A sort of Autoque let\'s say :) I use 2 functions:

-(void)goUp 
-(         


        
5条回答
  •  孤城傲影
    2020-12-10 09:15

    Actually, you can still pause the UIView animations based on the answer to the question that Vladimir linked to as it pause my CABasicAnimations as well as my UIView animations after I had implemented all my animations as CABasicaAnimations and then added some UIView animations afterwards that I had thought wouldn't be paused, but they didn't work either. This is the relevant link.

    I wanted to pause my whole view so I passed self.view.layer as the layer to be paused. But for those who don't know about CALayer's, pass in the view.layer that you want paused. Each UIView has a CALayer, so just pass in the upmost view.layer that is relevant for you. In the case of Thomas, based on your own answer, it would seem that you would want to pass in self.containerView.layer to be paused.

    The reason that this works is because UIView animations are simply a layer on top of Core Animation. At least that's my understanding.

    Hope this helps future people wondering how to pause animations.

提交回复
热议问题