Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode Interface Builder: Make a view's center X equal to third of its superview

I have a two views I'd like to place in a way that they are equally spaced horizontally.

I'd like to define thier Center X so that they are the third and two-thirds of the width of the superview but I have found no constraint setting that allows you to do that.

Can you tell me how can this be achieved?

enter image description here

like image 620
Zoltán Matók Avatar asked Sep 14 '25 15:09

Zoltán Matók


2 Answers

You can use a Center X constraint with the following settings:

Center X

For the second view the Multiplier has to be 2/3 of course.

Result: Result

like image 178
André Slotta Avatar answered Sep 17 '25 06:09

André Slotta


Select Align Center X from the subView and the Superview (screen of only the last one) enter image description here

Change the multiplier: 2:3 for the first one, and 4:3 for the second one:

enter image description here

like image 26
Larme Avatar answered Sep 17 '25 06:09

Larme