我必须在UICollevtionView中用红色显示角落单元格,并用绿色显示单元格的其余部分!
答案 0 :(得分:0)
您可以在cellForItemAtindexPath中添加特定索引路径的背景色
func collectionView(_ collectionView: UICollectionView,
cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "YouCustomCellIdentifier",
for: indexPath)
guard let checkMarkCell = cell as? YouCustomCell else {
return cell
}
if(indexPath.row == 0) {
cell.backgrouColor = UIColor.red
} else {
cell.backgrouColor = UIColor.green
}
return checkMarkCell
}