How to set keyboard animation time

I hope the main question is: is there an easy way to change the speed at which the keyboard opens? I can do this in the ViewDidLoad method:

[UIView setAnimationDuration:2.5]; 

And this will not only affect the speed at which my keyboard appears (slow slow), but also all other animations, such as the cursor animation (also dead slow). Is there a way to adjust the speed of one keyboard? [UIView.firstResponder setAnimationDuration:2.5]; does not work.

+4
source share
1 answer

I think I really need this:

 // Get the duration of the animation. NSValue *animationDurationValue = [userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey]; NSTimeInterval animationDuration; [animationDurationValue getValue:&animationDuration]; // Animate the resize of the text view frame in sync with the keyboard appearance. [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:animationDuration]; textView.frame = newTextViewFrame; [UIView commitAnimations]; 

I found this in an example Apple code illustrating how to add a panel on top of a keyboard. But I was still a little confused when I read somewhere else that the animation Friendship is read only. Anyway, this works, so I think this is the answer to my question.

+1
source

Source: https://habr.com/ru/post/1346224/


All Articles