SWIFT 快速简易收键盘
2015-07-07 本文已影响829人
孙朗斌
![](https://img.haomeiwen.com/i311306/67f6f918a396a3fd.jpg)
当不再需要使用虚拟键盘时,只要点击虚拟键盘和编辑区域外的地方,就可以将键盘收起,下面程式码是在 UIView 中内建的触碰事件方法函式,您可以参考Touch Panel / 触碰萤幕 / 压力感应器的基本使用方式一文,找到更多关于触碰事件的方法函式。
override func touchesEnded(touches:Set, withEvent event:UIEvent?) {
if!(userCodeTF.exclusiveTouch) {
userCodeTF.resignFirstResponder()
}
if!pwdTF.exclusiveTouch{
pwdTF.resignFirstResponder()
}
}