美文网首页
iOS-动画的暂停&继续

iOS-动画的暂停&继续

作者: malgee | 来源:发表于2019-08-16 15:25 被阅读0次
    - (void)pauseLayer
    {
        CFTimeInterval pausedTime = [self.layer convertTime:CACurrentMediaTime() fromLayer:nil];
        self.layer.speed = 0.0;
        self.layer.timeOffset = pausedTime;
    }
    
    - (void)resumeLayer
    {
        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;
    }
    

    相关文章

      网友评论

          本文标题:iOS-动画的暂停&继续

          本文链接:https://www.haomeiwen.com/subject/imqqsctx.html