Skip to content

Instantly share code, notes, and snippets.

@gmoraleda
Last active November 22, 2018 16:16
Show Gist options
  • Save gmoraleda/ddd24278c159dd21ec216ca130b28b50 to your computer and use it in GitHub Desktop.
Save gmoraleda/ddd24278c159dd21ec216ca130b28b50 to your computer and use it in GitHub Desktop.
let keyboard = KeyboardObserver()
override func viewDidLoad() {
super.viewDidLoad()
keyboard.observe { [weak self] (event) -> Void in
guard let self = self else { return }
switch event.type {
case .willShow, .willHide, .willChangeFrame:
// React to the keyboard and adapt your UI
updateInsets(for: event, scrollView: self.scrollView)
default:
break
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment