Cordova插件使用——Statusbar定制状态栏

小编:管理员 631阅读 2022.09.13

全称是:cordova-plugin-statusbar

什么时候用它呢?比如下面的场景:

image.png

因为应用标题栏背景有底色,而默认状态栏的文字颜色为黑色,看上去就没那么美观,所以我们可以去利用该插件改变状态栏的文字为协调的颜色。

那实际在ionic3里是怎么使用的?

因为该插件是项目默认安装的,所以我们直接使用即可,打开app.component.ts,找到下面代码

this.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.
      this.statusBar.styleDefault();
      this.splashScreen.hide();
    });
复制

把this.statusBar.styleDefault()改为this.statusBar.styleLightContent()即可,这是其中一种方式,还有其它方式,可以查看文档: https://github.com/apache/cordova-plugin-statusbar 其中列出其余方法如下:

StatusBar.overlaysWebView
StatusBar.styleDefault
StatusBar.styleLightContent
StatusBar.styleBlackTranslucent
StatusBar.styleBlackOpaque
StatusBar.backgroundColorByName
StatusBar.backgroundColorByHexString
StatusBar.hide
StatusBar.show
复制
关联标签: