Изменить содержимое текущей видимой ячейки - UICollectionViewCell - PullRequest
0 голосов
/ 27 сентября 2019

У меня есть UICollectionViewCell.У меня есть isPagingEnabled.Я хочу добавить цвет границы и тени, когда ячейка видна.Я добавил этот код, и он не работает.

extension CarouselTVC : UICollectionViewDelegate {

    func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "carouselCVC", for: indexPath) as! CarouselCVC
        cell.elevate(elevation: 8.0, color: .red, opacity: 0.16)
        cell.layer.borderWidth = 1.0
        cell.layer.borderColor = UIColor.red.cgColor

        print("Will Display")
    }

    func collectionView(_ collectionView: UICollectionView, didEndDisplaying cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "carouselCVC", for: indexPath) as! CarouselCVC

        cell.layer.borderWidth = 0.0
        cell.layer.borderColor = UIColor.clear.cgColor
        cell.layer.shadowOpacity = 0.0

        print("Did End Display")

    }

}

...