无法使用cordova-plugin-statusbar设置状态栏的颜色 [英] Can't set color of statusbar with cordova-plugin-statusbar
问题描述
我正在尝试更改 ionic 应用程序中本机状态栏的颜色,但无法正常工作.我已经安装了cordova-plugin-statusbar,它安装得很好.以下代码完美运行:
I'm trying to change the color of the native status bar in an ionic app, but I can't get it to work. I've installed cordova-plugin-statusbar, and it installs fine. The following code works perfectly:
if (StatusBar) {
StatusBar.hide();
}
但尝试使用任何其他可用功能,例如:
But trying to use any other of the available functions, for example:
if (StatusBar) {
StatusBar.backgroundColorByHex('#RRGGBB');
}
不起作用,只是应用程序使用标准状态栏.
doesn't work, the just app uses the standard statusbar.
我还在 config.xml 中添加了 <preference name="StatusBarOverlaysWebView" value="true"/>
,并在运行时以编程方式对其进行设置.
I've also added <preference name="StatusBarOverlaysWebView" value="true" />
to config.xml, as well as setting it programmatically at runtime.
Cordova 是 5.1.1 版,Ionic 是 1.5.5 版,我使用 Android 21 进行测试.有没有人遇到过同样的问题或知道如何解决?
Cordova is version 5.1.1, Ionic is version 1.5.5 and I'm using Android 21 for testing. Has anyone experienced the same problem or know how to fix it?
推荐答案
您能否尝试删除状态栏插件并像这样重新安装:
Could you try removing the status bar plugin and reinstalling like so:
ionic plugin rm org.apache.cordova.statusbar
ionic plugin add https://github.com/apache/cordova-plugin-statusbar.git
The same has been reported at the ionic issue tracker
这篇关于无法使用cordova-plugin-statusbar设置状态栏的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!