How do i resolve a default iOS system element, like say UISegmentedControl
, to a particular interface style?
I know colors can be resolved like this.
color.resolvedColor(with: UITraitCollection(userInterfaceStyle: .dark))
How do i do the same for default iOS elements?
You can override the system interface style by using UIView
property overrideUserInterfaceStyle
. Use this property to force the view to always adopt a light or dark interface style.
if #available(iOS 13.0, *) {
segmentedControl.overrideUserInterfaceStyle = .dark
}
For more details see docs here.
Relevant WWDC video - Implementing Dark Mode on iOS. (27:00)