超出superView的subview响应方法

it2022-05-09  20

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

  

}

  

转载于:https://www.cnblogs.com/KingQiangzi/p/9571147.html


最新回复(0)