Ronak Shah
Ronak Shah

Reputation: 1058

How to I align 4 buttons together? (autolayout)

I'm trying to align 4 buttons together so they look like this:

enter image description here

I want it so that ONE has a 0 margin to the left, right and bottom, TWO has a 0 margin to the left, right, and bottom, THREE has a margin to the top, left, and right, and FOUR has a 0 margin to the top, left, and right

In order to support iOS 8, I do not want to use stack views

Upvotes: 0

Views: 91

Answers (3)

PlusInfosys
PlusInfosys

Reputation: 3436

You can set proportion width for all four buttons. Set width = Superview.width and then Set multiplier =0.5 This will make sure that your button width is half of buttons superview so will fit two button in it.

To do so, Right click on Button, Drag to super view and select EqualWidth constraint. then go to constraint and edit multiplier of recently added width constraint to 0.5 (or 1:2). As in this image

You can check this video for detail

Upvotes: 1

Waqar Khalid
Waqar Khalid

Reputation: 119

Use Ctrl+click from one button to other button and choose equal width.All the buttons will have equal width in this way.

Upvotes: 0

Tj3n
Tj3n

Reputation: 9943

You can add 0 constraint to all their sides, then choose all at same time and give them equal width and height, if custom height then just need to set height constraint to 1 of them, then you can achieve the design

Upvotes: 2

Related Questions