如何将 UICollectionViewFlowLayout 与两列居中 [英] How can I center UICollectionViewFlowLayout with two columns

查看:30
本文介绍了如何将 UICollectionViewFlowLayout 与两列居中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 UICollectionView 我想要这个:

I have a UICollectionView where I want this:

[    x    x    ]
[    x    x    ]

每个 UICollectionViewCell 都是 120x120 使用:

Each UICollectionViewCell is 120x120 using:

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    return CGSizeMake(120, 120);
}

我不知道如何使两列居中.左中右等量.

I cannot figure out how to make the two columns center. With the same amount in the left, middle and right.

你能帮我解决这个问题吗?

Can you help me out with this?

谢谢!

推荐答案

使用 sectionInset 指定边距.使用 minimumInteritemSpacing 来确定项目之间的空间.

Use sectionInset to dictate the margins. Use minimumInteritemSpacing to determine the space between the items.

这篇关于如何将 UICollectionViewFlowLayout 与两列居中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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