In UIViewPropertyAnimator
, is there a way to just stop all UIViewPropertyAnimator
animations?
Or perhaps simply get all current animations - then of course you could stop
them all.
Can this be done?
Or do you really have to
UIViewPropertyAnimator
,and,
A UIViewPropertyAnimator object lets you animate changes to views and dynamically modify your animations before they finish. With a property animator, you can run your animations from start to finish normally or you can turn them into interactive animations and control the timing yourself.
UIViewPropertyAnimator was introduced in iOS 10. It allows you to create animations in object-oriented way. Let’s have at a sample animation created using UIViewPropertyAnimator.
Delaying the animation is quite easy too, just call the startAnimation function with the afterDelay param. UIViewPropertyAnimator adopts the UIViewImplicitlyAnimating protocol that provides the animator with some other interesting abilities.
As you have probably noticed with the previous example, together with the animation block we have defined two parameters: the duration of the animation and the animation curve, a UIViewAnimationCurve instance that can represents the most common curves (easeIn, easeOut, linear or easeInOut).
Every animation has to have atleast one UIViewPropertyAnimator instance. In order to stop the animation, we have to explicitly call stopAnimation(_:)
on the animator instance.
A way would be to make a factory class to fetch UIViewPropertyAnimator
instance and keep track of it in a set or array. And then use this factory class to stop or start all the animations at once. Or use one UIViewPropertyAnimator
to perform all your animations and stop it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With