I have an array of cells in a collection view that I want to get to act like buttons.
When I tap on one, I want that cell to highlight, and then change colors.
I'm able to initially set the color of the view.backgroundColor inside of the collectionViewCell us the cellForItemAtIndexPath
method. However, contrary to what I thought would work if I do this:
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
let cell: ButtonCollectionCell = collectionView.dequeueReusableCellWithReuseIdentifier("ButtonCell", forIndexPath: indexPath) as! ButtonCollectionCell
cell.cellBackgroundView.backgroundColor = UIColor.darkGrayColor()
}
the color still isn't changing...
Essentially I want these cells to behave exactly like a button. I want them to highlight to a lighter gray color upon touch (they are initially white) after I release my finger I want them to become a dark gray color.
If I touch again I want them to again highlight to a lighter gray color, and then become white again.
If didSelectItemAtIndexPath
isn't the way to do it, what is?