0

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

4

3 回答 3

2

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

对于灯光模式:

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

对于暗模式:

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

希望这可以帮助!

于 2020-02-20T14:08:20.237 回答
0

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

于 2020-02-21T08:48:06.593 回答
0

对于 Android,首先在 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>
于 2021-06-22T14:19:18.173 回答