Wojtek Dmyszewicz Wojtek Dmyszewicz - 4 months ago 32
iOS Question

Collapsed height UILabel (attributed text) in UICollectionViewCell but not in UITableViewCell

Attributed text of a UILabel inside a UICollectionViewCell is collapsed 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);
Comments