Wilson
Wilson

Reputation: 9136

How to preserve a UIButton size after adding to a UIStackView

I am still learning iOS development with AutoLayout and UIStackView, so bear with me.

Basically I add a UIStackView and UIButton separately on my storyboard's view and then I set a random height to my UIButton and afterwards I add my UIButton to the UIStackView.

My question: Why doesn't my UIButton preserve its height after adding to the UIStackView?

Any help here, It will be appreciated so much thanks!

Upvotes: 3

Views: 1699

Answers (1)

Rob Norback
Rob Norback

Reputation: 6599

Make sure you add a height constraint to your uibutton or the height will be over written when you add it to a stackview

Upvotes: 6

Related Questions