I'm currently animating one of my constraints in an animation block, however I wish to customise the animation type - further to that given by the preset UIVIewAnimationOptions:
UIView.animateWithDuration(2.0, delay: 0.3, options: UIViewAnimationOptions.CurveEaseInOut, animations: { () -> Void in
self.heightTransition.constant = self.view.bounds.height - 52
self.view.layoutIfNeeded()
}, completion: { (complete) -> Void in
})
I've looked into the potential of using a CAMediaTimingFunction, as shown here (http://cubic-bezier.com/#.44,.94,.79,-0.01), where you can pass in values to alter the animation style.
My question then is, how can I apply the use of CAMediaTimingFunction upon animating UIView constraints?
I don't know if it's possible to do it directly, because NSLayoutConstraint is part of the UIKit, while CALayer is part of the Core Animation. But for me works this approach, where i do my CABasicAnimation with custom cubic bezier animation curve, then on completion UIView returns to it's starting position defined by it's constraints before animation started(or i can set other constraints to my UIView in animation completion block.), you can paste this in empty new project if you want to play around:
As we can see in gif, constraints set to UIView preserved after animation completion.