Ionic:无法在深色模式下更改iOS状态栏的颜色



我正在Ionic中构建一个渐进式web应用程序,我想将其添加到我的主屏幕上,并更改iOS状态栏的背景颜色和文本颜色。

我所做的

我安装了:"@ionic-native/status-bar": "^5.0.0"

在index.html中,我定义了:

<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="apple-mobile-web-app-status-bar-style" content="default"/>

在app.component.ts:中

this.platform.ready().then(() => {
this.statusBar.styleDefault();
this.splashScreen.hide();
});

这里的问题是,由于我的iPhone处于黑暗模式,状态栏将是黑色的。无论我是否处于黑暗模式,我都希望状态栏背景始终为白色,文本颜色始终为黑色。

我已经尝试了很多东西,但都不起作用:

<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/>

<meta name="apple-mobile-web-app-status-bar-style" content="translucent"/>

this.platform.ready().then(() => {
this.statusBar.overlaysWebView(false);
this.statusBar.backgroundColorByName('white');
this.splashScreen.hide();
});

上面的第一个和第二个选项只是将状态栏背景和文本颜色设置为白色(这意味着你根本看不到状态栏(,而第三个选项没有任何变化(背景仍然是黑色(。

您可以将以下设置添加到您的config.xml中作为一种变通方法:

<config-file parent="UIUserInterfaceStyle" platform="ios" target="*-Info.plist">
<string>Light</string>
</config-file>

总部位于@unamanichttps://github.com/apache/cordova-plugin-statusbar/issues/148

最新更新