Thom
Thom

Reputation: 15052

Make two buttons fill up half the screen each

I have two buttons below my login form. They are laid out like this:

Login                               Sign Up

I want both buttons to fill up their half of the horizontal line and be 16 points apart. How do I set up constraints in interface builder to solve this problem?

Upvotes: 0

Views: 506

Answers (2)

Thom
Thom

Reputation: 15052

I ended up creating an empty label and centering it horizontally. I then placed buttons on either side and set constraints so that they expanded from the left margin to the middle label and the right margin to the middle label. This fixed the problem.

Upvotes: 2

Rahul
Rahul

Reputation: 152

Login button constraints

Proportional width of login button to superview

Sign up button constraints

Proportional width of signup button to superview

from what i could understand after reading your problem, the following images provide the solution to it. You can notice that the width of login button is 179.5 points and x position of signup button is 195.5 points which makes a difference of 16 points which is required. i have tested it on different views for iphone5 and iphoneSE as well and its working fine. Have the following constraints on both buttons as explained in the pics. do let me know if it was what you were looking for. Cheers.

Upvotes: 2

Related Questions