1

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?

Rakesha Shastri
  • 11,053
  • 3
  • 37
  • 50

1 Answers1

2

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)

Rakesha Shastri
  • 11,053
  • 3
  • 37
  • 50
Bilal
  • 18,478
  • 8
  • 57
  • 72
  • Ahhh... shucks. This should have struck me. I remember seeing this on their video where they talk about how you can set styles for windows, views, etc. Thanks mate. – Rakesha Shastri Aug 02 '19 at 04:29