Search code examples
iosobjective-cautolayoutnslayoutconstraint

How adjust label alignment using autolayout?


I have some labels on my screen.4 Labels can have dynamic value it can display integer number value as well as it can also display some word as START.I have given the following constraints:

  • Leading to image

  • Top to image

enter image description here

Now as the text increase there is enough space on left so that label can expand it's width.but as i have given leading to top image so it will not move more to left.So please tell how can i move it to left when text increase.I know i can do it with the help of making outlet of leading constraint and change its value. But is there any easy way of doing it ?


Solution

  • edit the leading Constraints to "less than equal to" '<=' and trailing fixed '=', whenever the label will have lengthier text its size will increase in the left side and be fixed on the right side

    enter image description here