Codey
Codey

Reputation: 1233

Autolayout - Modify center align with multiplier

I want to have to buttons, which are horizontally centered in the container. Because they would overlap I want them to be a little offset from the center. I tried it with the multiplier.

If the button is in the center (as normal) the multiplier is 1. So I thought that for the left button, I specify a multiplier of 1,2 and for the right button 0,8.

And also, why is the constraint of the left button moved an the other one not?

enter image description here enter image description here

Upvotes: 1

Views: 574

Answers (1)

vacawama
vacawama

Reputation: 154701

I can't speak to the behavior of the multiplier for the center align constraint. If I were doing this, I would:

  1. Create a view to hold both buttons. Drag both buttons into the new view.
  2. Pin the top, left, and bottom of TOR to the top, left, and bottom of the new view, all with constants of 0.
  3. Pin the top, right, and bottom of STRAFE to the top, right, and bottom of the new view, all with constants of 0.
  4. Pin TOR to STRAFE with a horizontal spacing of 20. Fix any misplaced views by updating their frames.
  5. Make the new view's color clear.
  6. Now you can click between the buttons and they will stay together. Center their containing view horizontally and give it a vertical constraint and you're done.

Upvotes: 1

Related Questions