简体   繁体   English

iOS 13 暗模式 objc 字符串

[英]iOS 13 dark mode objc strings

I want to disable dark mode within my app for iOS 13. And I prefer not to do so via info.plist.我想在我的应用程序中为 iOS 13 禁用暗模式。我不想通过 info.plist 这样做。 The reason is, plist uses a global setting, making UIUserInterfaceStyle affects earlier iOS versions aswell (creating conflicts).原因是,plist 使用全局设置,使得 UIUserInterfaceStyle 会影响早期的 iOS 版本(造成冲突)。 I only want to set it to light for iOS 13: This is my current code within my AppDelegate:我只想为 iOS 13 将其设置为亮:这是我的 AppDelegate 中的当前代码:

 if(@available(iOS 13, *)){
    window.overrideUserInterfaceStyle = UIUserInterfaceStyleLight;

}

This code snippet works for fixing statusBar color to light.此代码片段用于将 statusBar 颜色固定为亮。 But general strings within the app are still in "dark mode".但应用程序中的一般字符串仍处于“暗模式”。 Earlier white strings turn into black, and my app is already pretty dark as it is.早期的白色字符串变成黑色,我的应用程序已经很黑了。 How do I fix so strings in the app does not change it's colors by themselves in dark mode?如何修复应用程序中的字符串在暗模式下不会自行更改其 colors? I want a global code snippet and not go through every ViewController...我想要一个全局代码片段,而不是 go 通过每个 ViewController ...

Regards问候

iOS ignores Info.plist keys it doesn't know. iOS 忽略它不知道的Info.plist键。 So you can safely set UIUserInterfaceStyle to Light in your Info.plist , iOS prior to version 13 will ignore this key.因此,您可以在Info.plist安全地将UIUserInterfaceStyle设置为Light ,版本 13 之前的 iOS 将忽略此键。

Fixed the problem by calling:通过调用解决了这个问题:

    self.window.overrideUserInterfaceStyle = UIUserInterfaceStyleLight;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM