我在一个单元格中有一个imageView。然而,当我点击那个单元格时,没有任何视觉指示它被点击了。我希望它看起来像按钮内的imageView,当你点击按钮时,它会改变颜色。
func collectionView(collectionView: UICollectionView, shouldHighlightItemAtIndexPath indexPath: NSIndexPath) -> Bool {
let cell: UICollectionViewCell = collectionView.cellForItemAtIndexPath(indexPath)
// what do i do with the cell.imageView to change it's state to look like it was tapped?
}
func collectionView(collectionView: UICollectionView, shouldHighlightItemAtIndexPath indexPath: NSIndexPath) -> Bool {
let cell: IconCell = collectionView.cellForItemAtIndexPath(indexPath) as! IconCell
cell.imageView.alpha = 0.5
return true
}
func collectionView(collectionView: UICollectionView, didUnhighlightItemAtIndexPath indexPath: NSIndexPath) {
let cell: IconCell = collectionView.cellForItemAtIndexPath(indexPath) as! IconCell
cell.imageView.alpha = 1.0
}