Created
October 7, 2017 10:04
-
-
Save jimmythai/91f5550d0a1eee5efca5337e69202a8b 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
| import UIKit | |
| extension UIViewController { | |
| func hideKeyboardWhenTappedAround() { | |
| let tap = UITapGestureRecognizer(target: self, action: #selector(UIViewController.dismissKeyboard)) | |
| view.addGestureRecognizer(tap) | |
| } | |
| @objc func dismissKeyboard() { | |
| view.endEditing(true) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment