Created
November 12, 2020 17:24
-
-
Save jbadger3/963d9abe3c4bd00048f963ec0b97778d to your computer and use it in GitHub Desktop.
iOS manual keyboard dismissal
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
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