I'm pretty new to Swift and I have a question, I have a collection view, with a cell inside, and a label inside of this cell. I created an array and returned it, so I have multiple cells with labels. My question is, how to change a color of specific labels, for example if I want the labels "2", "7", "13"(from the image) and etc to be not green, but other color. THANK YOU screen of simulator
Asked
Active
Viewed 517 times
1
-
Set the label's color in the `cellForItemAt` method. – rmaddy Apr 24 '17 at 21:20
1 Answers
1
Implement method below and set desired colour.
func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
// Access label of cell object and set desired colour
}
Tells the delegate that the specified cell is about to be displayed in the collection view.
https://developer.apple.com/reference/uikit/uicollectionviewdelegate/1618087-collectionview

nspavlo
- 377
- 3
- 12