通常UICollectionViewのCellはタップ(選択)されてもCELLの色は変わりませんが、下記設定にて可能となる。
1、選択されたCellの色を変える設定
タップしたときの背景色
cell.selectedBackgroundView = dateManager.cellSelectedBackgroundView(UIColor.lightGrayColor())
2、セルをタップしている間は色を変え、離したら元の色に戻る処理。
func collectionView(collectionView: UICollectionView, didHighlightItemAtIndexPath indexPath: NSIndexPath) {
let cell = collectionView.cellForItemAtIndexPath(indexPath)!
cell.backgroundColor = UIColor.clearColor() // タップしているときの色にする
}
func collectionView(collectionView: UICollectionView, didUnhighlightItemAtIndexPath indexPath: NSIndexPath) {
let cell = collectionView.cellForItemAtIndexPath(indexPath)!
cell.backgroundColor = UIColor.darkGrayColor() // 元の色にする
}