改变颜色 statusBar Ionic

Change color statusBar Ionic

我想更改 ANDROID 中状态栏的颜色。我使用了这个代码

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();
    });

我在控制台没有错误。

我找到了解决方案。显然,当您创建一个新项目时,插件状态栏不可用。这很奇怪,因为它已经在 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();
    });