AutoLayout setting UILabel height to zero

前端 未结 5 1532
暗喜
暗喜 2021-02-14 01:40

I have a UILabel for item description amongst other views, all laid out using constraints in Interface Builder - you can see all relevant constraints in the image b

5条回答
  •  梦谈多话
    2021-02-14 02:41

    I managed to solve it by setting the UILabel's vertical compression resistance priority to 1000 (default 750) in Interface Builder.

    Since my views are embedded in another view, and the parent view's bottom is dependent on the bottom of the lowest child view, I only speculate that the UILabel without a height constraint was getting squeezed in the process of laying out the views. Probably playing with priorities of other constraints somewhere down the chain would have yielded the same result, but I wasn't able to do it successfully. The solution above, however, worked, which is good enough in my case.

    Hope this helps someone.

提交回复
热议问题