【发布时间】:2021-12-07 23:01:42
【问题描述】:
我附上了我想要的屏幕显示。我尝试了下面的代码,但没有得到显示结果
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ZigZagCollectionCell", for: indexPath) as! ZigZagCollectionCell
cell.setUpCell()
if indexPath.row % 2 == 0 {
cell.viewBG.backgroundColor = UIColor.red
} else {
cell.viewBG.backgroundColor = UIColor.green
}
return cell
}
我想要这种类型的集合视图。提前致谢。
【问题讨论】:
-
两个选项 1. 子类
UICollectionViewFlowLayout2. 使用compositional flow layout你会发现很多教程 -
谢谢。有什么参考链接可以帮助我吗?
-
@KamleshShinarakhiya 请查看链接raywenderlich.com/…
标签: ios swift iphone uicollectionview