在项目中发现Android和iOS在手机状态栏样式不一样,然后就查到有一个cordova插件可以解决这个问题

1.下载插件$cordovaStatusbar命令:

cordova plugin add https://github.com/apache/cordova-plugin-statusbar.git

2.在config.xml里面配置如下:





将此配置改为:
(否则在Android上状态栏显示不出来)

3.在app.js里面,如下:

 

判断手机是android 还是iOS来定义不同的样式,我的这个是在Android和iOS上都是背景色为黑色,字体为白色

if (cordova.platformId == 'android') {    
StatusBar.backgroundColorByHexString("#333");
}else{
$cordovaStatusbar.overlaysWebView(false);
$cordovaStatusbar.style(1);
StatusBar.styleLightContent();
$cordovaStatusbar.styleColor('black');
}

4.最后iOS结果如图:



具体请参考ngcordova官网,http://ngcordova.com/docs/plugins/statusbar/和https://github.com/apache/cordova-plugin-statusbar上的资料
    



转载于:https://www.cnblogs.com/xiaojun-zxj/p/4741809.html

更多相关文章

  1. Android开发入门之--Eclipse/Android配置
  2. 在 Android(安卓)Studio 中配置源码路径
  3. Android(安卓)中 控制 wifi
  4. Android使用自己封装的maven-publish插件(maven 和 maven-publis
  5. Android(安卓)Studio配置打包生成自定义文件名
  6. 自定义字体主题+自定义背景+设置radiobutton的字体的选中状态的
  7. Flutter 在 Android(安卓)Studio下环境配置
  8. 桌面便签程序的实现详解和源码 (上)
  9. Android(安卓)Annotations 学习之路(一)环境配置以及@EActivity在

随机推荐

  1. 自学android 坑2
  2. Android在子线程中更新UI(二)
  3. 源码剖析: Notification的发送
  4. Android(安卓)WebView的简单使用
  5. android PreferenceActivity使用
  6. android checkBox 的选中和取消选中
  7. Rect and RectF in Android(安卓)SDK
  8. Android(安卓)P ActivityManagerService(
  9. android ListView内数据的动态添加与删除
  10. 六步骤开发和发布自己的Android(安卓)Stu