How can you automatically reset the colors of all the subviews on a page?
I am defining dark mode colors doing something like this:
static let textColor: UIColor = UITraitCollection.current.userInterfaceStyle == .light ? .black : .white
If a user has the app open when dark mode automatically takes place (based off a user's settings) then the colors do not change. You have to close the app and re-open it to see dark mode.
How can you automatically reset the colors of all the subviews on a page?
This is what I tried:
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
view.layoutSubviews()
view.subviews.forEach {$0.layoutSubviews()}
}
LayoutSubviews does not reset the color.
Any ideas?
Thanks!