swift - 删除特定 UICollectionViewCells 之间的间距
问题描述
我正在使用在collectionItems之间UICollectionFlowLayout
建立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
}
解决方案
是否可以在 cellForItemAt 方法中进行更改以实现此目的
不,您要求做的不是 UICollectionViewFlowLayout 默认的行为方式。您将需要编写一个集合视图布局子类。
推荐阅读
- javascript - 如何从 Azure Active Directory (AAD) Web API 检索 access_token
- ios - iOS 状态栏背景重叠 UIAlertController
- angular - 如何在 Angular 6 中实现材料表?
- windows - 'conda' 未被识别为内部或外部命令
- matlab - 如何在 MATLAB 中从 MNA 方程组到状态空间 [A,B,C,D] mimo?
- python - 通过 Powershell 脚本运行 python 脚本
- ios - 发送 HTTP POST 请求时出现后台模式问题
- python - 使用 Selenium 和 Python 在不同网站上填写表格
- python - 如何将渠道和 DRF 整合在一起
- python - 在 matplotlib 文档中哪里可以找到 kwargs 的缩写?