希望有一个基本问题:是否有一种简单的方法可以改变键盘弹出的速度?我可以在 ViewDidLoad 方法中执行此操作:
[UIView setAnimationDuration:2.5];
它不仅会影响我的键盘弹出的速度(非常慢),还会影响所有其他动画,例如光标动画(也非常慢)。有没有办法单独针对键盘的速度? [UIView.firstResponder setAnimationDuration:2.5];
并没有真正起作用。
最佳答案
我想我实际上需要这个:
// Get the duration of the animation.
NSValue *animationDurationValue = [userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey];
NSTimeInterval animationDuration;
[animationDurationValue getValue:&animationDuration];
// Animate the resize of the text view's frame in sync with the keyboard's appearance.
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:animationDuration];
textView.frame = newTextViewFrame;
[UIView commitAnimations];
我在 Apple 的示例代码中发现了这一点,说明了如何在键盘顶部添加一个栏。但当我在其他地方读到动画持续时间是只读时,我仍然有点困惑。不管怎样,这有效,所以我想这就是我问题的答案。
关于iphone - 如何设置键盘动画时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5513293/