In my project, I got an array which I upload to my collectionview
var dataSource = ["@", "@", "1", "2", "3", "4", "5", "6", "7", "8" , "9", "10", "@", "@"]
for the string "@" I want to hide this particular cell. so initially I tried to do this with indexpath, and then tried to check if my array got the value "@". But I cannot hide it properly, as some other cells will be changed in the scroll
So this is what I did on my cellForItemAt :
if dataSource[indexPath.row] == "@" {
cell.contentView.isHidden = true
cell.layer.borderColor = UIColor.white.cgColor
}
It is believed that its scrolling is horizontal, and this is my sizeForItemAt :
func collectionView(_ collectionView: UICollectionView,
layout collectionViewLayout: UICollectionViewLayout,
sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize(width: (self.numberCollectionView?.bounds.size.width)!/5 - 3, height: (self.numberCollectionView?.bounds.size.width)!/5 - 3 )
}
source
share