iOS Keyboard show animation curve control points

Hi,


I'm current working on an application that uses many CALayer and I'd like to animate them when the keyboard apears on the screen. I've read many articles that shows how to retrieve the curve using the UIKeyboardAnimationCurveUserInfoKey however I'm unable to translate this curve into a CAMediaTimingFunction which can be then used with a CATransaction.


So, is there a way to convert a the curve into a CAMediaTimingFunction or, are the curve control points publicly available somewere ?


Thanks

In case this could help others, I tried to reverce-engineer the animation and I believe I came pretty close. For some reasons though, I needed to double the transaction duration and I then I used these control points:


CAMediaTimingFunction(controlPoints:0.380, 0.700, 0.125, 1.000)

If you print all CAAnimations in the UIViewAnimation block, you'll find that it's a CASpringAnimation when setting the animation curve to the one provided in keyboard notification. The duration is 0.5, and other parameters are:

let ani = CASpringAnimation(keyPath: someKey)
ani.damping = 500 
ani.stiffness = 1000
ani.mass = 3
ani.duration = 0.5


The code above can reproduce the animation precisely.

Once animation curve is set to the keyboard one, UIView animation will ignore the duration in the parameter. (If you really want to change the duration, adjust the

mass
value.)
iOS Keyboard show animation curve control points
 
 
Q