超出superView的subview响应方法

Posted kingqiangzi

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了超出superView的subview响应方法相关的知识,希望对你有一定的参考价值。

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

  

    }
    
   

  




以上是关于超出superView的subview响应方法的主要内容,如果未能解决你的问题,请参考以下文章