iOS 13 brings us UIUserInterfaceLevel
, which can be either .base
or .elevated
. The system seems to automatically adjust colors provided to UIView
when the elevated level is used in dark mode.
However, there seems to be no way how to manually specify the .elevated
color in the asset catalog, or is it?
The only way how to do it seems to be via the new UIColor constructor:
UIColor.init { (traits) -> UIColor in
traits.userInterfaceLevel == .elevated ? UIColor(named: "myColor-elevated")! : UIColor(named: "myColor")!
}