美文网首页
Swift convertTime

Swift convertTime

作者: 三秋树下 | 来源:发表于2017-10-21 10:03 被阅读22次

    CALayer的动画设置:

    extension CALayer {
        func pauseAnimate(){
            let pausedTime: CFTimeInterval = convertTime(CACurrentMediaTime(), from: nil)
            speed = 0.0;
            timeOffset = pausedTime;
        }
        
        func resumeAnimate(){
            let pausedTime: CFTimeInterval = timeOffset
            speed = 1.0;
            timeOffset = 0.0;
            beginTime = 0.0;
            let timeSincePause: CFTimeInterval = convertTime(CACurrentMediaTime(), from: nil) - pausedTime
            beginTime = timeSincePause;
        }
    }
    

    相关文章

      网友评论

          本文标题:Swift convertTime

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