gpt4 book ai didi

swift - 删除特定 UICollectionView 单元格之间的间距

转载 作者:行者123 更新时间:2023-11-28 13:33:52 27 4
gpt4 key购买 nike

我正在使用 UICollectionFlowLayout 在 collectionItems 之间建立 minimumLineSpacing,我试图找到一种方法将某些单元格的间距设置为零,这样就没有间距了,即它们似乎被“合并”,同时让其他人保持完整的空间,是否可以通过更改 cellForItemAt 方法来实现这一点?

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "customColCell", for: indexPath) as! customColCell

if indexPath.row == 5 {
self.minimumLineSpacing = 100 // -- this does not result in an individual change...
}

cell.textLabel.text = indexPath.row.description
return cell
}

最佳答案

is it possible to make alterations in the cellForItemAt method for example to achieve this

没有。您要执行的操作不是默认情况下 UICollectionViewFlowLayout 的行为方式。您将需要编写一个 Collection View 布局子类。

关于swift - 删除特定 UICollectionView 单元格之间的间距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56956504/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com