关于超出父视图的子视图点击事件

    override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {

        var view = super.hitTest(point, with: event)

        if view == nil {

            let point = self.convert(point, to: button)

            if button.bounds.contains(point) {

                view = button

            }

        }

        return view

    }


//其中button为我们超出的控件

猜你喜欢

转载自blog.csdn.net/lidongxuedecsdn/article/details/77882993