swift dismiss keyboard programmatically code example
Example: xcode hide keyboard when touch background storyboard
override func viewDidLoad()
{
super.viewDidLoad()
//Hide Keyboard
let tap = UITapGestureRecognizer(target: self.view, action: #selector(UIView.endEditing))
view.addGestureRecognizer(tap)
}