Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import UIKit
- extension UIView {
- public func hideKeyboardWhenTappedAround() {
- let tap: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(dismissKeyboard))
- tap.cancelsTouchesInView = false
- self.addGestureRecognizer(tap)
- }
- public func dismissKeyboard() {
- self.endEditing(true)
- }
- }
Add Comment
Please, Sign In to add comment