属性文本 UILabel 在 UICollectionViewCell 中被切断,但在 UITableViewCell



UICollectionViewCell中的属性文本UILabel在滚动后被切断(自动布局打开)。

为什么UITableViewCell中的相同设置工作正常。(约束/优先级也相同)

使用自定义字体和自动换行

通过提供 UILabel 属性首选的单元格宽度减去您在布局中使用的可能偏移量来解决该问题。

self.yourUIlabel.preferredMaxLayoutWidth = CGRectGetWidth(self.bounds) - yourOffsets;

在这里找到答案:http://johnszumski.com/blog/auto-layout-for-table-view-cells-with-dynamic-heights

类似的问题:自动换行不适用于UILabel

和UILabel有时无法正确换行文本(自动布局)

但是一些问题仍然存在,为什么我在UITableViewCell中不需要此属性

相关内容