xcode 如何在不使用 Any BaseUIViewController 的情况下为所有 UIViewController 禁用暗模式?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/56804047/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can i disable dark mode for all UIViewControllers without using Any BaseUIViewController?
提问by Mehmet Salih Aslan
Hello i read Apple Article for disable Dark Mode because i need disable for my all UIViewController and i haven't any BaseUIViewController.
您好,我阅读了禁用暗模式的 Apple 文章,因为我需要禁用所有 UIViewController 并且我没有任何 BaseUIViewController。
How can i disable Dark Mode for all UIViewController without using any BaseUIViewController. I don't want to write the following code over and over again.
如何在不使用任何 BaseUIViewController 的情况下为所有 UIViewController 禁用暗模式。我不想一遍又一遍地编写以下代码。
Is there a solution to this?
这个问题有方法解决吗?
override func viewDidLoad() {
super.viewDidLoad()
// Always adopt a light interface style.
overrideUserInterfaceStyle = .light
}
回答by Dávid Pásztor
You can force light/dark mode in your whole application regardless of the user's settings by adding the key UIUserInterfaceStyle
to your Info.plist
file and setting its value to either Light or Dark.
通过将密钥添加UIUserInterfaceStyle
到Info.plist
文件并将其值设置为 Light 或 Dark,您可以在整个应用程序中强制采用明/暗模式,而不管用户的设置如何。