Home>
UIWindow.appearance (). overrideUserInterfaceStyle
orself.overrideUserInterfaceStyle
on any UIViewController can only take.unspecified
.
How can I get the current appearance mode (.dark
or.light
) (which mode is currently displayed)? Please let me know if you know.
-
Answer # 1
-
Answer # 2
I don't think I have looked at it.
The user can choose light or dark, so just think about the color in the dark.Implementation example (in dark mode, simply return the opposite color of normal lightColor)
UIColor {(traitCollection: UITraitCollection)->UIColor in switch traitCollection.userInterfaceStyle { case .unspecified, .light: return lightColor case .dark: return lightColor.inverted @unknown default: return lightColor }
For reference only
https://qiita.com/tamappe/items/5a6031d8b8d39f1e5b4e
Trends
I was out of focus, I used it elsewhere
I confused
overrideUserInterfaceStyle
withtraitCollection.userInterfaceStyle