Created
May 22, 2018 13:51
-
-
Save RockinPaul/dd8634cab136da5e13cd617dfcaea7a0 to your computer and use it in GitHub Desktop.
Dismiss keyboard on tap in UIView
This file contains hidden or 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
override func viewDidLoad() { | |
super.viewDidLoad() | |
let tap = UITapGestureRecognizer(target: self, action: #selector(self.dismissKeyboard)) | |
tap.cancelsTouchesInView = false | |
self.view.addGestureRecognizer(tap) // Dismiss keyboard | |
} | |
func dismissKeyboard(gestureReconizer: UITapGestureRecognizer) { | |
self.view.endEditing(true) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment