It’s pretty easy, and not well known…
Simply add the following code in your ViewController.swift
override func touchesBegan(_ touches: Set
self.view.endEditing(true)
}
And boom! Any time you tap on the screen, the keyboard disappear!