Wojtek Dmyszewicz Wojtek Dmyszewicz - 1 year ago 130
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 Source

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