Skip to content

Instantly share code, notes, and snippets.

@ericjames
Last active June 28, 2017 20:58
Show Gist options
  • Save ericjames/1f616c4e4573507f454b671fa57fba98 to your computer and use it in GitHub Desktop.
Save ericjames/1f616c4e4573507f454b671fa57fba98 to your computer and use it in GitHub Desktop.
@IBOutlet weak var myTextField: UITextField!
// Dismisses keyboard by touching outside of keyboard
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
// Dismiss keyboard
self.view.endEditing(true)
}
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
myTextField.resignFirstResponder()
return true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment