Reputation: 365
I have a stackview that I am using as a dropdown menu by changing the spacing to collapse and expand the stack view.
There are buttons inside the stack view of the same size. When the spacing is negative they appear on top of each other. I set the layer zIndex to determine which button I want to show on top.
I was hoping this zIndex would also determine which button receives the tap notification but instead the last button in the stack view always receives the tap.
How can I make sure the visible button (with highest zIndex) is receiving the tap? Is there a better way for me to implement a collapsible menu of buttons?
Best regards
Upvotes: 0
Views: 293
Reputation: 8506
If you are using stackview and want to show/hide the button conditionally, then while hiding button, also write:
stackView.removeArrangedSubview(buttonInstance)
buttonInstance.removeFromSuperview()
Instrad of buttonInstance.removeFromSuperview()
, also try buttonInstance.isHidden = true
Upvotes: 0