Skip to content

Instantly share code, notes, and snippets.

@Pasanpr
Created March 7, 2016 21:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pasanpr/690dd3a7bc3d58528fd9 to your computer and use it in GitHub Desktop.
Save Pasanpr/690dd3a7bc3d58528fd9 to your computer and use it in GitHub Desktop.
Code for repositioning the text field
// Adding observer for notification
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(ViewController.keyboardWillHide(_:)), name: UIKeyboardWillHideNotification, object: nil)
// Repositioning the text field
func keyboardWillHide(notification: NSNotification) {
UIView.animateWithDuration(0.8) {
self.textFieldBottomConstraint.constant = 40
self.view.layoutIfNeeded()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment