Reputation: 1592
I want to make a floating menu in a view that will be later added to many tab view view controllers. So I want the view itself to be transparent and doesn't receive interactions while keeping users able to interact with the menu buttons.
As in the picture below:
I tried to set the view alpha to 0, it cascaded down to all its subviews.
Tried to set userInteractionEnabled to NO it did cascade down to all subviews as well.
Any suggestions??
Upvotes: 0
Views: 600
Reputation: 20710
Create a custom view and override
the pointInside:
, it returns false
when the point isn't within an eligible child view.
It could look like this:
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
for subview in subviews {
if !subview.hidden, subview.userInteractionEnabled, subview.frame.contains(point) {
return true
}
}
return false
}
Upvotes: 2