ios – 滚动后,Multiline UILabel底部被切断,UITableViewCell – > UIStackView – > UILabel

前端之家收集整理的这篇文章主要介绍了ios – 滚动后,Multiline UILabel底部被切断,UITableViewCell – > UIStackView – > UILabel前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
图层:UITableViewCell – > UIStackView – > UILabel,表高度设置为自动尺寸.

enter image description here

跑吧,一切都很好

enter image description here

在一些滚动之后,多线标签底部被切断

enter image description here

UILabel和堆栈视图设置:

enter image description here


enter image description here

布局堆栈视图的约束:

enter image description here

我试图将换行设置为自动换行,在标签调用sizeToFit,它们都不适合我.有线索吗?

解决方法

我过去解决这类问题的一种方法是将UILabel作为容器视图放在UIView中.然后将此容器放在UIStackView中,而不是将标签直接放在堆栈视图中.

您还可以尝试使用抗压优先级,因为标签似乎在缩小,因为它的抗压性不够高.

猜你在找的iOS相关文章