Created
May 18, 2021 13:11
-
-
Save matkuznik/d57e6f64a5eeb87884788cb1c56a2085 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class KeyboardAppearListener { | |
private var showKeyboard: NotificationToken? | |
private var hideKeyboard: NotificationToken? | |
private weak var viewController: UIViewController? | |
init( | |
_ viewController: UIViewController, | |
notificationCenter: NotificationCenter = .default) { | |
self.viewController = viewController | |
showKeyboard = notificationCenter.observe( | |
name: UIResponder.keyboardWillShowNotification) { [weak self] (notification) in | |
self?.keyboardWillShow(notification: notification) | |
} | |
hideKeyboard = notificationCenter.observe( | |
name: UIResponder.keyboardWillHideNotification) { [weak self] (notification) in | |
self?.keyboardWillHide(notification: notification) | |
} | |
} | |
private func keyboardWillShow(notification: Notification) {} | |
private func keyboardWillHide(notification: Notification) {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment