Swift convertTime

2017-10-21  本文已影响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;
    }
}
上一篇下一篇

猜你喜欢

热点阅读