How to switch programmatically to dark mode swift

社会主义新天地 提交于 2020-11-29 04:18:12

问题


How can I make a switch to change programatically to dark or light mode in my iOS app? I'm using Swift.


回答1:


You can override the style for single views or view controller using the overrideUserInterfaceStyle property. But since the window is also a view, you can set that on your main window to force it into light or dark mode:

window.overrideUserInterfaceStyle = .dark


来源:https://stackoverflow.com/questions/60171262/how-to-switch-programmatically-to-dark-mode-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!