我在单元格内部有一个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?
}
答案 0 :(得分:1)
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
}