swift基础--点击空白处收起键盘
2019-02-21 本文已影响0人
111ZZzz
1.全屏收起键盘
//注册监听
self.view.addGestureRecognizer(UITapGestureRecognizer(target:self, action:#selector(当前ViewController.handleTap(sender:))))
//事件
func handleTap(sender: UITapGestureRecognizer) {
if sender.state == .ended {
当前TextView/当前TextField.resignFirstResponder()
}
sender.cancelsTouchesInView = false
}
持续更新..