How to cancel UIView block-based animation?

前端 未结 4 1567
栀梦
栀梦 2020-11-29 04:22

I\'ve searched loads of SO stuff and in Apple\'s references, but still unable to manage my problem.

What I have:

  1. A screen with 2 UIImageView
4条回答
  •  天命终不由人
    2020-11-29 04:59

    For iOS 10 use UIViewPropertyAnimator to animate. It provides methods to start, stop and pause UIView animations.

     let animator = UIViewPropertyAnimator(duration: 2.0, curve: .easeOut){
            self.view.alpha = 0.0
     }
     // Call this to start animation.
     animator.startAnimation()
    
     // Call this to stop animation.
     animator.stopAnimation(true)
    

提交回复
热议问题