如何使用部分在CollectionView中水平居中行

问题描述 投票:0回答:1

所以我知道这个话题在过去已经解决了,但是,我已经尝试应用之前的所有建议,但实际上并没有解决我的问题。

我有一个collectionView包含动态数量的部分和项目,我需要约束所有行水平居中。

我已经尝试应用一个名为KTCenterFlowLayout的吊舱,但没有成功,因为显然它不适用于多节collectionView

无论如何在swift 4中以多部分qazxsw poi为中心uicollectionView行?

uicollectionview swift4
1个回答
0
投票
CollectionView

在你的视图控制器中写下它,并设置你想要的任何东西.'func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { let screenWidth = (UIScreen.main.bounds.size.width-4) / 3 return CGSize(width:screenWidth , height: screenWidth); }'

© www.soinside.com 2019 - 2024. All rights reserved.