IOS How to Cancel UIView Animation

I reset the restriction and make the animation ( self.view.layoutIfNeeded()) a delay of 3 seconds, in some cases I want to remove the animation, what should I do, I tried self.view.layer.removeAllAnimations(), but did not work

this is my animation code

UIView.animateWithDuration(0.3, delay: 3, options: UIViewAnimationOptions.CurveEaseInOut, animations: { () -> Void in
    self.messageViewLeftConstraint.constant = 36
    self.view.layoutIfNeeded()
}, completion: { (finished) -> Void in           
})

this is the cancellation code i tried

self.view.layer.removeAllAnimations()
+4
source share

Source: https://habr.com/ru/post/1619790/


All Articles