Autolayout - 2 Labels with dynamic length

时间:2015-10-30 23:10:10

标签: ios swift autolayout

I have a question about Autolayout - normally i dont have any problems using autolayout, if a cell label has a dynamic length - but it this case ill got 2 labels, 1 top label with a dynamic length, and a second one under the first label.

Ill tried to set to the top label a leading, trailing, a fixed width (its an ipad landscape app, so i want to have and exact with) - and to the second one a bottom, trailing, and set the leading to the first label. Like here:

enter image description here enter image description here enter image description here

But i am unable to bring that to work that:

Both labels should have an dynamic length - so update the cell height automatically. Width of both Labels is 700px, width an margin top, right and bottom is 8.

Ill forgot to say, but the left label should have a dynamic height too.

Any ideas? Thanks in advance!

Errors after using "Lukas" Tipp:

enter image description here

1 个答案:

答案 0 :(得分:1)

By default, both labels will have a same hugging and resistance priority, making one of them less than the other would fix the problem. Ps, I'd avoid using magic numbers like 8 in your auto layout, instead use standard value