//MARK:- Keyboard
private func setupNotifications() {
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow), name: UIResponder.keyboardWillShowNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide), name: UIResponder.keyboardWillHideNotification, object: nil)
}
@objc func keyboardWillShow(notification: Notification) {
if let keyboardFrame: NSValue = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue {
let keyboardRectangle = keyboardFrame.cgRectValue
let keyboardHeight = keyboardRectangle.height
bottomConstraint.constant = keyboardHeight
self.view.updateConstraintsIfNeeded()
self.view.layoutIfNeeded()
}
}
@objc func keyboardWillHide(notification: Notification) {
bottomConstraint.constant = 0
self.view.updateConstraintsIfNeeded()
self.view.layoutIfNeeded()
}