Where to highlight UICollectionViewCell: delegate or cell?

后端 未结 7 2521
渐次进展
渐次进展 2020-12-13 09:43

According to the Collection View Programming Guide one should handle the visual state of the cell highlights in the UICollectionViewDelegate. Like this:

相关标签:
7条回答
  • 2020-12-13 10:24

    It is enough for highlighting cell (Swift 4)

    class MyCollectionViewCell: UICollectionViewCell {
    ...
        override var isHighlighted: Bool {
            didSet {
                if isHighlighted {
                    self.contentView.alpha = 0.6
                }
                else {
                    self.contentView.alpha = 1.0
                }
            }
        }
    }
    
    0 讨论(0)
提交回复
热议问题