【问题标题】:Ionic: cannot change iOS status bar color in dark modeIonic:在深色模式下无法更改 iOS 状态栏颜色
【发布时间】:2020-08-18 01:22:28
【问题描述】:

我正在 Ionic 中构建一个渐进式网络应用程序,我想将其添加到我的主屏幕并更改 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 处于黑暗模式。我想要的是始终将状态栏背景设为白色,将文本颜色设为黑色,无论我是否处于暗模式。

我已经尝试了很多东西,但都没有奏效:

&lt;meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/&gt;

&lt;meta name="apple-mobile-web-app-status-bar-style" content="translucent"/&gt;

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

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

【问题讨论】:

    标签: ios angular ionic-framework progressive-web-apps ios7-statusbar


    【解决方案1】:

    您可以将以下设置添加到您的 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

    【讨论】:

      猜你喜欢
      • 2020-01-21
      • 2020-02-08
      • 2022-01-09
      • 1970-01-01
      • 1970-01-01
      • 2016-11-04
      • 2018-08-27
      • 2022-12-14
      • 2020-10-02
      相关资源
      最近更新 更多