When doing UIView.animateWithDuration, I would like to define a custom curve for simplicity, not the default: .CurveEaseInOut, .CurveEaseIn, .CurveEaseOut, .CurveLinear.
This is an example of ease that I want to apply to UIView.animateWithDuration:
let ease = CAMediaTimingFunction(controlPoints: Float(0.8), Float(0.0), Float(0.2), Float(1.0))
I tried to make my own UIViewAnimationCurve, but it seems to only accept one Int.
I can apply custom lightness to Core Animation, but I would like to simplify and optimize the code for UIView.animateWithDuration. UIView.animateWithDuration is better for me, since I will not need to define an animation for each animated property and simpler completion handlers and have all the animation code in one function.
Here is my broken code:
let customOptions = UIViewAnimationOptions(UInt((0 as NSNumber).integerValue << 50)) UIView.setAnimationCurve(UIViewAnimationCurve(rawValue: 5)!) UIView.animateWithDuration(2, delay: 0, options: customOptions, animations: { view.layer.position = toPosition view.layer.bounds.size = toSize }, completion: { finished in println("completion") })
ios swift uiviewanimation
brandon koopa
source share