Created
July 22, 2016 12:16
-
-
Save bestimmaa/875dbb41660c9502c2e72ee98d517a37 to your computer and use it in GitHub Desktop.
Handle UIKeyboard for form screens on iOS
This file contains 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 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