Created
August 13, 2018 22:07
-
-
Save Arrlindii/15646c3efbe8f07a72f4bd099f5ffd57 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
| func configureKeyboardListeners() { | |
| NotificationCenter.default.addObserver(forName: Notification.Name.UIKeyboardWillShow, object: nil, queue: nil) { notification in | |
| let keyboardFrame = notification.userInfo![UIKeyboardFrameEndUserInfoKey] as! CGRect | |
| let keyboardHeight: CGFloat = keyboardFrame.height | |
| self.scrollView.contentInset.bottom = keyboardHeight | |
| self.scrollView.scrollIndicatorInsets.bottom = keyboardHeight | |
| } | |
| NotificationCenter.default.addObserver(forName: Notification.Name.UIKeyboardWillHide, object: nil, queue: nil) { notification in | |
| self.scrollView.contentInset.bottom = 0 | |
| self.scrollView.scrollIndicatorInsets.bottom = 0 | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment