Reputation: 13837
I've designed those 5 button in my storyboard based on iPhone6. Now problem is my client told me to make their app can be workable in iPhone5 onwards. Current those 5 buttons in iPhone5 cannot be displayed proportionally as same width. That's why my question is please let me know how to make same width for 5 button horizontally in xcode?
Upvotes: 3
Views: 1458
Reputation: 468
Using a stackView works great but for those whose target is below iOS 9, you can do it very simply with autolayout. Just select all 5 labels and use the "pin" icon on the bottom of the storyboard to check "equal width".
Upvotes: 2
Reputation: 59536
As already said in the comments you can create an Horizontal Stack View. Then add the 5 buttons to the Stack View.
Finally you can select the spacing by selecting the Stack View and, in the Attribute Inspector, increasing the Spacing
field.
Upvotes: 0
Reputation: 16735
Try this:
UIButton
s to yourViewController.UIStackView's
attribute inspector, make sure it's "horizontal", distribution is set to "Fill Equally", and adjust the spacing to whatever you want.UIStackView
to left/right, top/bottom.It should look something like this when you're done:
Upvotes: 2