1

I want to add separator lines using auto layouts constraints.

enter image description here

The idea is to have some percent dependencies. So for example let's say that first line under first label is equal about 70 percent of superview then I need to layout second label and second line starting from 70 percent + paddings. So then second line should be less than 30% of total width.

Maybe also it's possible to do with NSLayoutConstraint constraintWithItem

The main question is how to set percentage.

Matrosov Oleksandr
  • 25,505
  • 44
  • 151
  • 277

1 Answers1

2

This is what the multiplier of a constraint is for. Set the width of the first line to be equal to the width of its superview, but with a multiplier of 0.7 (or thereabouts).

You can set that in code or in Xcode (Interface Builder).

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • ok got cha and then for example if I have 3 paddings left centre and right I should decrease the width using this values. let's say I have 320 width and the left padding equal 20pt then centre padding equal 5pt and right padding after second line equal 10pt. Then I should set width 320 - 35 = 285. Correct? for both lines with multiplier 0.7 and 0.3? – Matrosov Oleksandr May 25 '15 at 20:57