Search code examples
iosautolayout

Understanding what "greater than or equal" and "less than or equal" are in Auto Layout


suppose I have this layout:

enter image description here

I would like to set contraint from trailing of the color view to the superview in such a way that when the label expands, it will push the colored view to the right, but not exceeding the screen.

So, what I understand is, setting trailing of the colored view to superview with less than or equal relationship will do the trick. But it does not.

enter image description here

So, what is really the use of greater than or equal and less than or equal anyway?


Solution

  • set color view's trailing constraint to greater than or equal to some constant! And it will manage space equal to that constant!

    Your label should be self sizing, I mean should increase width with content and you should give fixed width to your color view!