chiahsien/CHTCollectionViewWaterfallLayout

Resize cell height according to dynamic label

adelburekovic opened this issue · 3 comments

How can i tackle the problem of resizing the CollectionViewCell height according to the dynamic label inside it? I was thinking worst case scenario would be to calculate label height according to text inside the label?
Is there any cleaner way?

Any suggestions would be greatly appreciated!

No, you already got the best way. LOL

Maybe i explained the problem too vaguely.

I have several different collectionView cells that include static views and dynamic label with different font sizes.

As far as i can see it i'll need to get the font and text size for each different collectionView cell label and calculate number of lines for the given string and increase the base height according to the number of lines in sizeForItemAtIndexPath method.

I was wondering maybe if there was some easier solution that i missed similar to UITableViewAutomaticDimension

As far as I know, this may be the best way to reach your goal.

Somebody tried auto layout and/or self-sizing before, but didn't get good result.
In this year's WWDC, Apple announced enhanced auto cell sizing for collection view flow layout. I haven't studied it yet, but I don't think it will help.