【问题标题】:Change color statusBar Ionic更改颜色状态Bar Ionic
【发布时间】:2018-06-02 19:16:39
【问题描述】:

我想在 ANDROID 中更改 statusBar 的颜色。我用了这段代码

constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) {
    platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      statusBar.styleDefault();
      statusBar.backgroundColorByHexString('#E91E63');
      splashScreen.hide();
    });

我在控制台中没有错误。

【问题讨论】:

  • 您正在设备上运行,对吗?您可以尝试检查 statusBar 是否可见:console.log('Is visible?',this.statusBar.isVisible);
  • 我找到了解决方案@HumbertodeCarvalho 我需要再次安装插件 $ ionic cordova plugin add cordova-plugin-statusbar

标签: angular cordova ionic-framework ionic2 ionic3


【解决方案1】:

我找到了解决方案。显然,当您创建新项目时,插件状态栏不可用。这很奇怪,因为它已经在 app.component.ts 中使用了。

反正我只是安装了插件

 $ ionic cordova plugin add cordova-plugin-statusbar

然后在 app.component.ts 中

platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      statusBar.styleDefault();
      statusBar.backgroundColorByHexString('#87173c');
      splashScreen.hide();
    });

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-08-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-18
    • 2019-05-21
    • 2016-10-25
    • 1970-01-01
    相关资源
    最近更新 更多