hallz13
hallz13

Reputation: 69

How to stretch all buttons inside horizontal stack view as device width

I have difficulty to stretch all 5 buttons inside horizontal stack view as wide as my device width. Can I do that? or do you guys have any solutions?

Looking forward to your answer. Thank you very much for your attention.

Upvotes: 1

Views: 2401

Answers (3)

Martin Muldoon
Martin Muldoon

Reputation: 3436

  • Add a Horizontal Stack View
  • Add Constraint - Center Vertically in container
  • Pin the stack view to the left and right view after unchecking constrain to margins.
  • Add or drag your buttons into the stack view.
  • Select your stack view in Document Outline, and then in Attribute Inspector change Distribution to Fill Equally.
  • Done![enter image description here]1

Upvotes: 2

If you have an horizontal stack view, set its constraints to left and right of the superview and the distribution to Fill Equally, so the buttons will fill the view in an equally way.

Upvotes: 1

Martin Muldoon
Martin Muldoon

Reputation: 3436

Simply select the five buttons, and add them to a stack view. Then pin the stack view to the left and right of the superview. The buttons will automatically span the entire view's horizontal space. See image below: enter image description here

Upvotes: 0

Related Questions