答案 0 :(得分:1)
您需要在viewDidLoad
中以这种方式在视图中添加点按手势
let tapGesture:UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(self.viewTapped(_:)))
self.view.addGestureRecognizer(tapGesture)
现在在viewTapped
ViewController
func viewTapped(sender: UITapGestureRecognizer){
self.dismissViewControllerAnimated(true, completion: nil)
}