Guest User

Untitled

a guest
Jun 19th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. import UIKit
  2.  
  3. extension UIView {
  4.  
  5. public func hideKeyboardWhenTappedAround() {
  6. let tap: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(dismissKeyboard))
  7. tap.cancelsTouchesInView = false
  8. self.addGestureRecognizer(tap)
  9. }
  10.  
  11. public func dismissKeyboard() {
  12. self.endEditing(true)
  13. }
  14.  
  15. }
Add Comment
Please, Sign In to add comment