iOS Autolayout: two buttons of equal width, side by side

Stack layout in iOS9, will do the job really nice. Add stack view to your view and configure as follow:

enter image description here


Add the following constraints

  1. Assign equal width from button1 to button2.
  2. Assign horizontal spacing between both buttons.
  3. Assign leading space from button1 to its superview.
  4. Assign trailing space from button2 to its superview.
  5. Assign top space to both the buttons.
    Let me know if it works for you.

Follow Steps and Screenshots for easy solution


Step-1)

  • For Button 1 : Set Constraints: (1)Leading, (2)Top or Bottom asper your need, (3)Height


Step-2)

  • For Button 2 : Set Constraints: (1)Trailing,(2)Top or Bottom asper your need, (3)Height

Step-3)

  • Press Ctrl + Drag From Button 1 to Button 2

  • Select Horizontal Spacing


Step-4)

  • Select Both Button (using Command) and Add Constraints Equal Width


OUTPUT

Hope it Helps you :)