Skip to content

Instantly share code, notes, and snippets.

@oalansari82
Created July 5, 2020 16:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oalansari82/d734c2fbae6e9e2e17207142aa5da211 to your computer and use it in GitHub Desktop.
Save oalansari82/d734c2fbae6e9e2e17207142aa5da211 to your computer and use it in GitHub Desktop.
How to dismiss the keyboard by tap
extension UIView {
open override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesBegan(touches, with: event)
UIApplication.shared.windows
.first { $0.isKeyWindow }?
.endEditing(true)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment