Zoltán Matók Zoltán Matók - 1 month ago 12
iOS Question

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

Answer Source

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