Reputation: 31
I am trying to add a button to an image view which lies in a stack view. But whenever I try to add the button after adding the image view, the stack view gets divided into two parts, one housing the button and the other housing the image view.
I want to add an icon which is an image view, on top which there's a button which one clicked does the needful.
Upvotes: 0
Views: 947
Reputation: 2460
Instead of using a button, first add a uiview in place of button and then add image and button inside the uiview.
Upvotes: 0
Reputation: 19737
Just add the button to the stackView
and use background on that button to set the icon:
button.setBackgroundImage(UIImage(named: "icon"), for: .normal)
Or through storyboards select a button and set it in attributes inspector:
Upvotes: 2