ppshein ppshein - 2 months ago 5x
iOS Question

How to make same width for 5 button horizontally in xcode

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?


Try this:

  1. Add 5 UIButtons to yourViewController.
  2. Highlight buttons
  3. Click "Stack" icon at the bottom of the storyboard window.
  4. On the UIStackView's attribute inspector, make sure it's "horizontal", distribution is set to "Fill Equally", and adjust the spacing to whatever you want.
  5. Pin the UIStackView to left/right, top/bottom.

It should look something like this when you're done:

enter image description here