I use below code to get keyboard height. Then use this height to calculate the frame of an UIView to make sure this UIView just on the top of the k
override func viewDidLoad() { super.viewDidLoad()
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow), name: UIResponder.keyboardWillShowNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide), name: UIResponder.keyboardWillHideNotification, object: nil)
}
//Here keyboard is without any toolbar and suggestions boxes
@objc func keyboardWillShow(notification: NSNotification) {
if let keyboardSize = (notification.userInfo?[UIResponder.keyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue {
let keyboardHeight = ((keyboardSize.height) > 240) ? 220 : (keyboardSize.height - 47)
self.view.layoutIfNeeded()
}
}