Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jbadger3/963d9abe3c4bd00048f963ec0b97778d to your computer and use it in GitHub Desktop.
Save jbadger3/963d9abe3c4bd00048f963ec0b97778d to your computer and use it in GitHub Desktop.
iOS manual keyboard dismissal
extension UIApplication {
func addTapGestureRecognizer() {
guard let window = windows.first else { return }
let tapGesture = UITapGestureRecognizer(target: window, action: #selector(UIView.endEditing))
tapGesture.cancelsTouchesInView = false
tapGesture.delegate = self
tapGesture.name = "MyTapGesture"
window.addGestureRecognizer(tapGesture)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment