Create and apply Themes.
-
Use
ThemeController
as the root VCThemeController(viewController: UIViewController)
- Create a
ThemeSegue
with the identifier"ThemeSegue"
-
Create themes
let mainTheme = Theme(...)
let secondTheme = Theme(...)
- Create and use a
ThemeContext
let themeContext = ThemeContext(theme: mainTheme)
themeContext.controllers.append(themeController)
// Set every UIColor to the `themeContext.*` equivalent
- Switch themes
self.themeContext.animateTheme(secondTheme)
class MyContext: ThemeContext {
public var customColor: UIColor {
if #available(iOS 13.0, tvOS 13.0, *) {
return Color.make { traitCollection -> UIColor in
return self.currentTheme.customColor.resolvedColor(with: traitCollection)
}
} else {
return self.currentTheme.customColor
}
}
}
class MyTheme: Theme {
public var customColor: UIColor
public init(customColor: UIColor) {
self.customColor = customColor
super.init()
}
}