Fry
Fry

Reputation: 6275

UICollectionViewFlowLayout with items of different size

I have an UICollectionView where the items can modify at run time it's height. The problem is that when an item is higher than another, the item are surrounded by a lot o blank space.

enter image description here

I'm looking for a property that create this:

enter image description here

and I want use UICollectionView not github example or third part implementation. Thanks.

Upvotes: 4

Views: 793

Answers (1)

Gilad Ronat
Gilad Ronat

Reputation: 34

I don't believe UICollectionViewFlowLayout behaves this way. Try to reload your collection view after modifying the height or returning a different value for that cell in collectionView:layout:sizeForItemAtIndexPath: and see if the gap fills. Otherwise, I'd recommend using a custom UICollectionViewLayout subclass.

This class might fit this purpose properly - a UICollectionViewLayout subclass to work with your collection view: https://github.com/aceisScope/WaterflowView/blob/master/WaterFlowDisplay/WaterFlowLayout.h

Upvotes: 1

Related Questions