Wojtek Dmyszewicz Wojtek Dmyszewicz - 5 months ago 55
iOS Question

Attributed text UILabel cut off in UICollectionViewCell but not in UITableViewCell

Attributed text UILabel inside a UICollectionViewCell is cut off after scrolling (autolayout turned on).

Why does the same setup in a UITableViewCell is working fine. (the constraints / priority levels are identical as well)

Using a custom font.

Answer

Resolved it by providing the cell width for the UILabel property preferredMaxLayoutWidth.

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

Found the answer here: http://johnszumski.com/blog/auto-layout-for-table-view-cells-with-dynamic-heights