简体   繁体   English

如何将UICollectionViewFlowLayout用两列居中

[英]How can I center UICollectionViewFlowLayout with two columns

I have a UICollectionView where I want this: 我有一个UICollectionView我想要的地方:

[    x    x    ]
[    x    x    ]

Each UICollectionViewCell is 120x120 using: 每个UICollectionViewCell的大小为120x120使用:

- (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? 你能帮我这个忙吗?

Thanks! 谢谢!

Use sectionInset to dictate the margins. 使用sectionInset来指定边距。 Use minimumInteritemSpacing to determine the space between the items. 使用minimumInteritemSpacing确定项目之间的空间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 UICollectionViewFlowLayout 中为两列居中按钮? 是否有更有效的方法来解决这个问题? - How can I center Buttons within UICollectionViewFlowLayout for two columns? Might there be a more efficient way to solve this? 如何在2个不同的UICollectionViewFlowLayout实例之间切换? - How can I toggle between 2 different UICollectionViewFlowLayout instances? 如何使用UICollectionViewFlowLayout将集合中的每个视图居中? - How to center each view in the collection with UICollectionViewFlowLayout? 如何获取UICollectionViewFlowLayout以使单元格跨越多行? - How can I get UICollectionViewFlowLayout to have an cell span multiple rows? 如何在方向更改时重新计算UICollectionViewFlowLayout? - How do I recalculate UICollectionViewFlowLayout on orientation change? 如何将两个并排的UILabel水平居中? - How can I horizontally center two side-by-side UILabels? UICollectionViewFlowLayout的行和列 - Rows and columns of UICollectionViewFlowLayout 带有两个 UICollectionViewFlowLayout 的 UICollectionView - UICollectionView with two UICollectionViewFlowLayout UICollectionViewFlowLayout-如何获得行和列的偶数间距? - UICollectionViewFlowLayout - How do I get even row and column spacing? 我如何通过两列实现此侧边栏菜单-iOS? - How I can achieve this sidebar menu with two columns - IOS?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM