当应用程序处于后台时,暂停的动画结束

时间:2017-11-24 13:21:52

标签: ios swift animation uiview

我有一个观点,我正在使用此

移动
func r() {
    movel.constant = self.view.bounds.width - self.move.bounds.width
    move.setNeedsLayout()
    UIView.animate(withDuration: time, delay: 0, options:[], animations: {
        self.move.superview?.layoutIfNeeded()
        }, completion: {(finished: Bool) -> Void in
            if (finished == true){
                self.timerand()
                self.l()
            }else{
                self.view.layoutIfNeeded()
            }
    })
}

我正在使用这些功能来暂停和恢复它

func movestop() {
    pausedmovetime = self.move.layer.convertTime(CACurrentMediaTime(), from: nil)
    self.move.layer.speed = 0.0
    self.move.layer.timeOffset = pausedmovetime
}

func movestart() {
    self.move.layer.speed = 1.0
    self.move.layer.timeOffset = 0.0
    self.move.layer.beginTime = 0.0
    let timeSincePause = self.move.layer.convertTime(CACurrentMediaTime(), from: nil) - pausedmovetime
    self.move.layer.beginTime = timeSincePause
}

该应用程序工作正常,但当我离开应用程序时,我调用movestop(),但当我回来时它处于最终位置并且完成块不会被调用

0 个答案:

没有答案