Swift 手势点击区域 拾遗
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
self.endEditing(false)
for touch:AnyObject in touches {
let t:UITouch = touch as! UITouch
let touchPoint = t.location(in: self)
if self.chatContainView.frame.contains(touchPoint) {// 这里排除不需要触发点击事件的范围(rect内)
print("点击的这块儿不会有反应!")
}else {
print("hide view")
self.hide()
// 此处进行操作
}
}
}
网友评论