UICollectionView 流布局没有固定的行高 [英] UICollectionView Flow layout no fixed row height

查看:19
本文介绍了UICollectionView 流布局没有固定的行高的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何修改流式布局,使小单元格和大单元格之间的垂直间距相同(例如,没有固定的行高/行高不固定为最大尺寸)?

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)?

我想看起来像这样

推荐答案

解决方案是使用 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;

    ...
}

这篇关于UICollectionView 流布局没有固定的行高的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆