UICollectionViewのCell選択では標準ではCell選択されても色が変わらないが下記の記述で指定できる。
1、タップしたときの背景色
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() // 元の色にする
}