标签:uiview hit poi 事件 swift bounds pre let contain
view的响应事件传递 在superView里面用 hitTest(_ point: CGPoint, with event: UIEvent?) 方法,找出事件响应区域内的point 传递给subVIew即可
public override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
var view = super.hitTest(point, with: event) if view == nil { for subView in self.subviews { let tp = subView.convert(point, from: self) if subView.bounds.contains(tp) { view = subView } } } return view
}
标签:uiview hit poi 事件 swift bounds pre let contain
原文地址:https://www.cnblogs.com/KingQiangzi/p/9571147.html