UICollectionView Flow layout no fixed row height

我的未来我决定 提交于 2019-12-01 11:17:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!