About
I tried to create a project where you can globally change the appearance of the application.
Perhaps someone was looking for such a solution.
Themes
.unspecified
The appearance of the system is used..light
Permanent light appearance..dark
Permanent dark appearance.
Colors
.red
.pink
.orange
.yellow
.green
.blue
.purple
- Your own colors that you like.
SceneDelegate
func scene(_ scene: UIScene,
willConnectTo session: UISceneSession,
options connectionOptions: UIScene.ConnectionOptions) {
self.window?.overrideUserInterfaceStyle = AppearanceService.shared.theme.getUserInterfaceStyle()
self.window?.tintColor = AppearanceService.shared.color.getColorStyle()
}
AppDelegate
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
if UserDefaults.standard.object(forKey: DefaultKeys.switchState) == nil {
UserDefaults.standard.set(true, forKey: DefaultKeys.switchState)
}
if UserDefaults.standard.object(forKey: DefaultKeys.selectedColor) == nil {
UserDefaults.standard.set(5, forKey: DefaultKeys.selectedColor)
}
return true
}