ios - 如何在 UICollectionView 中居中行?

标签 ios objective-c uicollectionview

我有一个带有随机单元格的 UICollectionView。有什么方法可以让我居中行吗?

默认情况下是这样的:

[ x x x x x x ]  
[ x x x x x x ]  
[ x x         ]  

这是所需的布局:

[ x x x x x ]  
[ x x x x x ]  
[    x x    ]  

最佳答案

我必须做这样的事情,但需要一个部分中的所有单元格。将 UICollectionViewFlowLayout 扩展到中心单元非常简单。我做了一个 pod :

https://github.com/keighl/KTCenterFlowLayout

enter image description here

关于ios - 如何在 UICollectionView 中居中行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16544186/

相关文章:

ios - 从 MPMediaQuery 获取用于 UITableView 的部分标题列表(数组)?

objective-c - Testflight 没有完全安装

ios - 原型(prototype)单元格中带有 CollectionView 的动态 TableView

ios - 如何在按下按钮时在 Collection View 中滚动(水平)?

ios - Swift 4 - 以编程方式在 AutoLayout UITableViewCell 中切碎多行标签

ios - 我正在快速处理收藏夹,在 favorite_btn 上单击我想将按钮的图像从星号更改为星号。填充

iphone - 澄清 Objective-C 中的属性

ios - 动画切换 CollectionViewLayout

ios - 图像未显示在 Apple Watch 上

iphone - iOS 7 中的 RemoteControlReceivedWithEvent 问题