Swift 3 点击屏幕任意位置隐藏键盘

前端之家收集整理的这篇文章主要介绍了Swift 3 点击屏幕任意位置隐藏键盘前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
func hideKeyboardWhenTappedAround() {
        let tap: UITapGestureRecognizer = UITapGestureRecognizer(target: self,action: #selector(UIViewController.dismissKeyboard))
        tap.cancelsTouchesInView = false
        view.addGestureRecognizer(tap)
    }

猜你在找的Swift相关文章