Как изменить цвет фона угловой ячейки в uicollectionView - PullRequest
0 голосов
/ 25 сентября 2018

Мне нужно отобразить угловую ячейку красным цветом, а остальную ячейку зеленым в UICollevtionView! enter image description here

1 Ответ

0 голосов
/ 25 сентября 2018

Вы можете добавить цвет фона определенного пути индекса в 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
}
...