I have one collection view with some cells. Inside my cells, I have one shortcut to show a list of country names. And each time I click on each label, I will show some data in the form of a table under my collection view.
When I click on any cell label, I need to turn this label text in red. And other label names should be black.
How to do it? I tried the code below, but when I select any label name in this cell, all the cell labels turn red.
How to fix it?
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
if let cell = collectionView1.cellForItemAtIndexPath(indexPath) {
var label = cell.viewWithTag(100) as? UILabel
label!.textColor = UIColor.redColor()
}
}
source
share