Reputation: 956
I've already implement a custom cell using auto layout like this:
It has 4 parts as you can see: [thumbnail, title, summary, feedName]
.
I need to layout title
& summary
beautifully. They're both multi-line UILabels.
What I need to achieve is that when there are too many texts, the summary's line count gets decreased first, then the title's, not like what the picture is showing (the title only occupies one line).
I've tried setting the hugging and resistance priorities like this, but it's not working, any ideas?
title:
summary:
Upvotes: 2
Views: 835
Reputation: 956
Seems I need to always set the preferredMaxLayoutWidth for a multi-line label, even its width can be calculated by constraints to surrounding views.
By setting this, it's working perfectly now.
self.titleLabel.preferredMaxLayoutWidth = maxLayoutWidth;
self.summaryLabel.preferredMaxLayoutWidth = maxLayoutWidth;
Upvotes: 5