美文网首页
【iOS Swift 笔记1】退出键盘

【iOS Swift 笔记1】退出键盘

作者: 卖鱼家的少爷 | 来源:发表于2017-05-06 10:36 被阅读0次

项目里面很多东西要删掉了
所以在这里记一些笔记

    // 退出键盘-点击其他地方1
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        view.endEditing(true)
    }
    // 退出键盘-点击其他地方2
    override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
        [YourTextField].resignFirstResponder()
     }
    // 退出键盘-点击return键 [UITextFieldDelegate]
    func textFieldShouldReturn(_ textField: UITextField) -> Bool {
        textField.resignFirstResponder()
        return true
    }

相关文章

网友评论

      本文标题:【iOS Swift 笔记1】退出键盘

      本文链接:https://www.haomeiwen.com/subject/ccuetxtx.html