iOS: springWithDamping like animation for KeyFrame animation
Asked Answered
A

0

9

I had the following custom transition using UIView.animateWithDuration(...usingSpringWithDamping:...) which worked perfectly.

UIView.animateWithDuration(self.transitionDuration(transitionContext),
    delay: 0.0, usingSpringWithDamping: 0.8, initialSpringVelocity: 1.0,
    options: nil, animations: {() in
    // ...
}, completion: {(Bool) in
    // ...
})

But then I had to extend my custom transition with UIViewControllerInteractiveTransitioning in order to have an interactive transition where the user can swipe down the modal view again.

Therefore I needed keyframes for the animation in order that the UIPercentDrivenInteractiveTransition works properly.

So I changed the animation function to use UIView.animateWithKeyframes....

UIView.animateKeyframesWithDuration(self.transitionDuration(transitionContext),
    delay: 0.0, options: UIViewKeyframeAnimationOptions.CalculationModeCubic,
    animations: {() in
    // ...
}, completion: {(Bool) in
    // ...
})

My problem now: I lost the spring animation.

I've checked several links, one of the most promising was:

... but with .addKeyframes... method I cannot specify a completion block that I need.

Any suggestions? :-/

Attemper answered 28/4, 2015 at 16:56 Comment(2)
did you look at github.com/felixjendrusch/Marionette ?Zacharyzacherie
as an aside, checkout this post on spring animations medium.com/@flyosity/…Dogbane

© 2022 - 2024 — McMap. All rights reserved.