Looked intoUIKeyboardAnimationDurationUserInfoKey
but I just can\'t find anywhere how to set it to a custom value.
The answer of @Vadoff works perfect. Here for Swift 3:
override func viewDidLoad() {
super.viewDidLoad()
//...
// Add observer to notificationCenter so that the method didShowKeyboard(_:) is called when the keyboard did show.
NotificationCenter.default.addObserver(self, selector: #selector(type(of: self).didShowKeyboard(_:)), name: NSNotification.Name.UIKeyboardDidShow, object: nil)
// Make textField the first responder.
textField.becomeFirstResponder() // <- Change textField to the name of your textField.
}
func textFieldDidBeginEditing(_ textField: UITextField) {
// Disable animations.
UIView.setAnimationsEnabled(false)
}
func didShowKeyboard(_ notification: Notification) {
// Enable animations.
UIView.setAnimationsEnabled(true)
}