I am looking to determine how the keyboard will animate in. On iOS 6 I get a valid value for the UIKeyboardAnimationCurveUserInfoKey
(which should be a UIViewAnimationCurve
with a value from 0-3) but the function returns a value of 7. How does the keyboard animate in? What can be done with the value of 7?
NSConcreteNotification 0xc472900 {name = UIKeyboardWillChangeFrameNotification; userInfo = {
UIKeyboardAnimationCurveUserInfoKey = 7;
UIKeyboardAnimationDurationUserInfoKey = "0.25";
UIKeyboardBoundsUserInfoKey = "NSRect: {{0, 0}, {320, 216}}";
UIKeyboardCenterBeginUserInfoKey = "NSPoint: {160, 588}";
UIKeyboardCenterEndUserInfoKey = "NSPoint: {160, 372}";
UIKeyboardFrameBeginUserInfoKey = "NSRect: {{0, 480}, {320, 216}}";
UIKeyboardFrameChangedByUserInteraction = 0;
UIKeyboardFrameEndUserInfoKey = "NSRect: {{0, 264}, {320, 216}}";
}}
It seems that the keyboard is using an undocumented/unknown animation curve.
But you can still use it. To convert it to a UIViewAnimationOptions for block animations shift it by 16 bits like so
UIViewAnimationCurve keyboardTransitionAnimationCurve;
[[notification.userInfo valueForKey:UIKeyboardAnimationCurveUserInfoKey]
getValue:&keyboardTransitionAnimationCurve];
keyboardTransitionAnimationCurve |= keyboardTransitionAnimationCurve<<16;
[UIView animateWithDuration:0.5
delay:0.0
options:keyboardTransitionAnimationCurve
animations:^{
// ... do stuff here
} completion:NULL];
Or just pass it in as an animation curve.
UIViewAnimationCurve keyboardTransitionAnimationCurve;
[[notification.userInfo valueForKey:UIKeyboardAnimationCurveUserInfoKey]
getValue:&keyboardTransitionAnimationCurve];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationCurve:keyboardTransitionAnimationCurve];
// ... do stuff here
[UIView commitAnimations];
I can't comment unfortunately otherwise I would instead of entering a new answer.
You can also use:
animationOptions |= animationCurve << 16;
This may be preferred as it will retain previous OR = operations on the animationOptions.
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