Swift touchesBegan 点击空白处响应事件
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesBegan(touches, with: event)
guard let touch = touches.first else {
return
}
let touchePoint = touch.location(in: self)
//判断是否点击到了不包含的view
if animateContainerView.frame.contains(touchePoint) {
} else {
dismiss()
}
}









网友评论