Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need assistance setting two buttons of equal width, side by side Autolayout

Using auto layout I am trying to create two buttons on the bottom like this

enter image description here

After dragging two buttons I set constraints like this

enter image description here

On Back button I set Leading Space to Container Margin and Bottom Space to Bottom Layout Guide

On Go To Settings button I set Trailing Space to Container Margin and Bottom Space to Bottom Layout Guide

Then I ctrl+Drag from Back button to Go To Settings button and set the Equal Widths constraint and I get this.

enter image description here

Then I update the Back button width same as Go To Settings button which is 101 and all constraints turn to blue.

But I want both buttons to cover half of the screen no matter what the size of screen is, same as shown in first screen shot, How to accomplish this?

like image 978
S.J Avatar asked Apr 14 '15 06:04

S.J


2 Answers

you can done it using equal width to 2nd button like this

enter image description here

and the output is

enter image description here

Here is apple guide

like image 160
EI Captain v2.0 Avatar answered Oct 01 '22 04:10

EI Captain v2.0


You can have the equal widths constraint between the buttons, but you also have to tell them which is that width you need.

So drag from a button to the superview, add an equal widths constraint. Then in the properties of the constraint you've added, set the multiplier to 0.5, this way your buttons should be on half the screen.

like image 40
Levi Avatar answered Oct 01 '22 05:10

Levi