iOS 子视图超出父视图范围并响应事件
2020-10-27 本文已影响0人
lczalh
在父视图中重写 func point(inside point: CGPoint, with event: UIEvent?) -> Bool
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
if self.bounds.contains(point) {
return true
}
for subView:UIView in self.subviews {
let hitPoint = self.convert(point, to: subView)
if subView.bounds.contains(hitPoint) {
return true
}
}
return false
}