以下をViewControllerに記述する。画面のどこかをタップするとキーボードが閉じるようになる。
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { self.view.endEditing(true) }