I want to have a dark mode option within the settings page of my Xcode swift app. Is it possible to change dark mode just for the app, on all view controllers in the app? I have my dark colors selected in 'Assets.xcassets'
Asked
Active
Viewed 1,761 times
1
-
3Does this answer your question? [How to switch programmatically to dark mode swift](https://stackoverflow.com/questions/60171262/how-to-switch-programmatically-to-dark-mode-swift) – hisam Aug 15 '20 at 23:50
1 Answers
3
If you want to set your app to be only on dark mode, you can simply add
overrideUserInterfaceStyle = .dark
to your viewDidLoad()
, or if you want it to be on the entire app:
- Go to your
Info.plist
file - Add new key:
UIUserInterfaceStyle
with valueDark

אורי orihpt
- 2,358
- 2
- 16
- 41
-
1Is it possible to switch all view controllers from a button or something – Henhen1227 Aug 16 '20 at 15:49
-
I think yes, try adding `overrideUserInterfaceStyle = .dark` to your button's action – אורי orihpt Aug 17 '20 at 13:49
-
Thank you! I managed to get it to work using `window?.overrideUserInterfaceStyle = .dark` in scene view controller – Henhen1227 Aug 17 '20 at 15:49
-