【问题标题】:Unable to use only Light or Dark theme on Nativescript无法在 Nativescript 上仅使用 Light 或 Dark 主题
【发布时间】:2020-02-18 08:58:54
【问题描述】:

我正在使用 Angular 8.2 和带有 scss 主题的 @nativescript/theme 2.2.1 开发 Nativescript(版本 6.3.3)应用程序。 无论系统模式(深色/浅色)如何,我都尝试仅使用深色(或仅浅色)主题,但似乎没有任何效果。 我遵循本指南https://github.com/NativeScript/theme 并使用自定义颜色变量将深色变量设置为浅色变量,但它不起作用。 有人可以支持我吗?

【问题讨论】:

    标签: nativescript-angular app-themes android-darkmode


    【解决方案1】:

    如果您只想在 iOS 上强制使用 Light 或 Dark 模式,您可以将以下内容添加到 Info.plist 文件中。

    对于灯光模式:

        <key>UIUserInterfaceStyle</key>    
        <string>Light</string>    
    

    对于深色模式:

        <key>UIUserInterfaceStyle</key>    
        <string>Dark</string>    
    

    希望这会有所帮助!

    【讨论】:

      【解决方案2】:

      另外,{N} Theme 2.3.x 有一些重要的修复来强制该模式。尝试使用 2.3.2。

      【讨论】:

        【解决方案3】:

        对于安卓, 首先在 main.ts 或 main.js 中添加这段代码

        import Theme from "@nativescript/theme";
        Theme.setMode(Theme.Light);
        

        然后将位于文件夹 values-v29 中的 styles.xml 文件中的此值从 true 更改为 false

        <item name="android:forceDarkAllowed">false</item>
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2019-07-25
          • 1970-01-01
          • 2014-06-16
          • 2021-12-09
          相关资源
          最近更新 更多