问题
How to modify the flow layout, so that there is the same vertical spacing between the smaller and larger cells (eg. there is no fixed row height / the row height is not fixed to the maximal size)?
I want to look it like this
回答1:
The solution was using UICollectionViewWaterfallLayout
Follow the setup from the website, and you can setup it like this
- (void)viewDidLoad
{
[super viewDidLoad];
UICollectionViewWaterfallLayout * layout = (UICollectionViewWaterfallLayout *)self.collectionView.collectionViewLayout;
layout.delegate = self;
layout.columnCount = 2;
layout.itemWidth = 150.f;
layout.sectionInset = UIEdgeInsetsZero;
...
}
来源:https://stackoverflow.com/questions/17047515/uicollectionview-flow-layout-no-fixed-row-height