Weird Autolayout Issue iOS

时间:2016-04-04 16:42:59

标签: ios autolayout ios-autolayout

I'm trying to accomplish the following view:

enter image description here

So what I have is a view and 6 labels, the top two labels have both leading and trailing space to container of 0, the bottom left two labels have leading space to container of 0, the bottom right two have trailing space to container of 0, and I have a spacing of 12 in between the bottom left two and the bottom right two.

However, this is what I get when I run it:

enter image description here

How can I fix it so it looks more like the first picture?

1 个答案:

答案 0 :(得分:2)

Do you have an "equal width" constraint between the left labels and the right ones ? Without it, your "weird" issue is in fact totally right according to your constraint :

The left label tries to expand its width to the maximum possible. How can it ? By minimising the width of the right label, which is why it looks shrinked, but in the way its frame contains exactly the text "Label".

Select the left and right labels and add an "Equal widths" constraint in interface builder.