How to create percentage of total width using autolayout?

If, as you say, you know how to do it in code, then you already know how to do it in the storyboard. It’s exactly the same constraints, but you are creating them visually rather than in code.

  1. Select both a view and its superview.

  2. Choose Editor -> Pin -> Widths Equally to constrain the width to be equal to the superview’s width (actually the “pin” popup dialog at the bottom of the canvas works best here).

  3. Edit the constraint and set the Multiplier to the desired fraction, e.g. 0.42. And so too for the other views.

Leave a Comment