swift3.0 点击UIScrollView中输入框之外的区域关闭键盘

通过点击事件实现关闭键盘

scrollView: UIScrollView!
title_textField: UITextField!
let hideKeyboardTapGesture = UITapGestureRecognizer(target: self, action: #selector(hideKeyboardTapGesture(sender:)))
scrollView.isUserInteractionEnabled = true
scrollView.addGestureRecognizer(hideKeyboardTapGesture)

关闭实现

func hideKeyboardTapGesture(sender: UITapGestureRecognizer){
        title_textField.resignFirstResponder()
}

 

posted @ 2017-05-12 17:43  昨天的李小白  阅读(422)  评论(0编辑  收藏  举报