ios13 Dark Mode change not recognized by tableview Cell?

前端 未结 2 1893
没有蜡笔的小新
没有蜡笔的小新 2021-01-24 22:57

I\'m checking my existing app to work correctly with the new introduced dark mode feature of ios 13.

Everything seems to work fine, only the cell background in one of m

相关标签:
2条回答
  • 2021-01-24 23:36

    If this gradient is on every cell of this type, then it should simply be a part of the cell, not inserted by the containing view controller. Then, in your cell, you can implement:

    
    override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
      super.traitCollectionDidChange(previousTraitCollection)
    
      if traitCollection.userInterfaceStyle != previousTraitCollection?.userInterfaceStyle {
        // reload the gradient layer to react
      }
    }
    
    

    You could also implement this in your view controller and reload data but it's messier.

    0 讨论(0)
  • 2021-01-24 23:54

    Cell will detect, layer will not! You must manually update all layer adaptations in the cell for example.

    override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
        super.traitCollectionDidChange(previousTraitCollection)
    
        if traitCollection.hasDifferentColorAppearance(comparedTo: previousTraitCollection) {
            removeAndReaddGradientIfNeeded()
        }
    }
    

    More description here

    0 讨论(0)
提交回复
热议问题