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
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.
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