[英]Ionic: cannot change iOS status bar color in dark mode
我正在 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>
基於@unamanic 在https://github.com/apache/cordova-plugin-statusbar/issues/148
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.