When the parent view has userInteractionEnabled=NO, its subviews will not accept touch events even if their userInteractionEnabled property is set to YES.
Is there a
Swift solution- You need to have a custom view class for the parent view and add the following code to it. Please keep the parent view's user-interactions enabled.
I hope the following code will help you.
class MyCustomParentView: UIView {
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
let hitView = super.hitTest(point, with: event)
if hitView == self {
return nil
} else {
return hitView
}
}
}