Here's how I do it (at least when the keyboard is about to be shown)
- (void)keyboardWillShow:(NSNotification *)notification {
NSDictionary *keyboardAnimationDetail = [notification userInfo];
UIViewAnimationCurve animationCurve = [keyboardAnimationDetail[UIKeyboardAnimationCurveUserInfoKey] integerValue];
CGFloat duration = [keyboardAnimationDetail[UIKeyboardAnimationDurationUserInfoKey] floatValue];
[UIView animateWithDuration:duration delay:0.0 options:(animationCurve << 16) animations:^{
// Set the new properties to be animated here
} completion:nil];
}
You get the animation curve from the keyboard notification as usual and translate it to an animation option by bit-shifting it.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…