How to pause and resume UIView Animation?

后端 未结 5 1376
长发绾君心
长发绾君心 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:08

    Hope it will help you.

    - (void)goUP{
        CFTimeInterval pausedTime = [self.layer timeOffset];
        self.layer.speed = 1.0;
        self.layer.timeOffset = 0.0;
        self.layer.beginTime = 0.0;
        CFTimeInterval timeSincePause = [self.layer convertTime:CACurrentMediaTime() fromLayer:nil] - pausedTime;
        self.layer.beginTime = timeSincePause;
    }
    
    - (void)goDown{
        CFTimeInterval pausedTime = [self.layer convertTime:CACurrentMediaTime() fromLayer:nil];
        self.layer.speed = 0.0;
        self.layer.timeOffset = pausedTime;
    }
    

    When you call the Layer animate, it will effect all layer tree and submode layer animate.

提交回复
热议问题