Skip to content

Instantly share code, notes, and snippets.

@bestimmaa
Created July 22, 2016 12:16
Show Gist options
  • Save bestimmaa/875dbb41660c9502c2e72ee98d517a37 to your computer and use it in GitHub Desktop.
Save bestimmaa/875dbb41660c9502c2e72ee98d517a37 to your computer and use it in GitHub Desktop.
Handle UIKeyboard for form screens on iOS
func keyboardShow(notification: NSNotification) {
let info: NSDictionary = notification.userInfo!
let frameV: NSValue = info[UIKeyboardFrameEndUserInfoKey] as! NSValue
let frame: CGRect = frameV.CGRectValue()
UIView.animateWithDuration(0.2, animations: {
() in
self.sview.contentInset = UIEdgeInsetsMake(0, 0, frame.size.height, 0)
})
}
func keyboardHide(notification: NSNotification) {
UIView.animateWithDuration(0.2, animations: {
() in
self.sview.contentInset = UIEdgeInsets(top: 64, left: 0, bottom: 0, right: 0)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment