首页 > 代码库 > swift回收键盘

swift回收键盘

//注册点击事件

        self.view.addGestureRecognizer(UITapGestureRecognizer(target:self, action:#selector(你的viewcontroller.handleTap(sender:))))

//对应方法

func handleTap(sender: UITapGestureRecognizer) {
        if sender.state == .ended {
            你的textfield.resignFirstResponder()
        }
        sender.cancelsTouchesInView =false
    }

 
 

swift回收键盘