tning
tning

Reputation: 1251

How align 2 buttons in a row using auto layout?

Basically, I want to align 2 buttons in the same row, with about 1/3 responsive spacing between buttons and edges, like the following picture:

IMG

However, what's inside the simulator is like this:

img

Constraints added for each button are:

IMG

Therefore, is there any way to align these 2 buttons correctly in a row using auto layout?

Upvotes: 1

Views: 2070

Answers (2)

rintaro
rintaro

Reputation: 51911

You should use "spacer" view like this:

screenshot

constraint like
H:|[spacer1][button1(120)][spacer2(==spacer1)][button2(120)][spacer3(==spacer1)]|

Upvotes: 3

gabbler
gabbler

Reputation: 13766

Control drag from one button to the other button, select horizontal spacing.

Upvotes: 1

Related Questions