Reputation: 3071
Using auto layout I am trying to create two buttons on the bottom like this
After dragging two buttons I set constraints like this
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.
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?
Upvotes: 7
Views: 3077
Reputation: 22374
you can done it using equal width to 2nd button like this
and the output is
Here is apple guide
Upvotes: 25
Reputation: 3733
You can followed the layout changes. you will get what you want.
Layout for Back
button.
Layout for
Go to Setting
button.
Upvotes: 0
Reputation: 1382
You need to add one more constraint - set horizontal space between buttons to 0
Upvotes: 1
Reputation: 7343
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.
Upvotes: 2