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

全称是: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
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容