Last active
December 13, 2018 16:56
-
-
Save ayoub-9/652f1eb85db4e90d6e94b44607887a02 to your computer and use it in GitHub Desktop.
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
| extension UIViewController { | |
| func hideKeyboardWhenTappedAround() { | |
| let tap: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(UIViewController.dismissKeyboard)) | |
| tap.cancelsTouchesInView = false | |
| view.addGestureRecognizer(tap) | |
| } | |
| func dismissKeyboard() { | |
| view.endEditing(true) | |
| } | |
| } | |
| ----- | |
| call him in ViewDidLoad | |
| self.hideKeyboardWhenTappedAround() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment