The French Guy

XCODE 11 – How to hide the keyboard by tapping anywhere on the screen



It’s pretty easy, and not well known…
Simply add the following code in your ViewController.swift

override func touchesBegan(_ touches: Set, with event: UIEvent?) {
self.view.endEditing(true)
}

And boom! Any time you tap on the screen, the keyboard disappear!

Leave a Reply

Your email address will not be published. Required fields are marked *