According to the Collection View Programming Guide one should handle the visual state of the cell highlights in the UICollectionViewDelegate
. Like this:
Notice that UICollectionViewCell
has a selectedBackgroundView
property. By default, it's nil. Just create a view for this property, and it will appear when the user touches the cell.
override func awakeFromNib() {
super.awakeFromNib()
let view = UIView(frame: contentView.bounds)
view.isUserInteractionEnabled = false
view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
view.backgroundColor = UIColor(white: 0.94, alpha: 1.0)
selectedBackgroundView = view
}