超出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

  

    }
    
   

  

posted @ 2018-09-01 18:14  Qiang zi  阅读(288)  评论(0编辑  收藏  举报