Skip to content

Instantly share code, notes, and snippets.

@iosharry
Created December 13, 2019 12:12
Show Gist options
  • Save iosharry/7c51a395a21c45c9c9937ea1ba70e502 to your computer and use it in GitHub Desktop.
Save iosharry/7c51a395a21c45c9c9937ea1ba70e502 to your computer and use it in GitHub Desktop.
KeyboardControllable
@objc protocol KMKeyboardControllable {
@objc func keyboardState(notification: Notification)
}
extension KMKeyboardControllable {
func setKeyboardNotification() {
NotificationCenter.default.addObserver(self, selector: #selector(keyboardState(notification:)), name: UIResponder.keyboardWillShowNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(keyboardState(notification:)), name: UIResponder.keyboardWillHideNotification, object: nil)
}
func removeKeyboardNotification() {
NotificationCenter.default.removeObserver(self, name: UIResponder.keyboardWillShowNotification, object: nil)
NotificationCenter.default.removeObserver(self, name: UIResponder.keyboardWillHideNotification, object: nil)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment