Hbuilder 修改状态栏的颜色

最近在看HBuilder文档时针对顶部状态栏如何隐藏/显示及如何设定颜色的一些常用方法

第一中方法: mui.init()方法是用来初始化内容页面,在这里可以直接设置状态栏的颜色
mui.init({
        statusBarBackground:"#FF0000"
    });
第二种方法: 在plusready中增加事件的方式来实现:
document.addEventListener('plusready',function(){
        plus.navigator.setStatusBarBackground("#FF0000");
  },false);

Android平台暂时不支持自定义系统状态栏样式

但可以通过离线打包在AndroidManifest.xml中配置主Activity的皮肤(Android:theme)来设置:

<activity
      android:name="io.dcloud.PandoraEntry"
               android:configChanges="orientation|keyboardHidden|screenSize"
       android:label="@string/app_name"
       android:launchMode="singleTask"
       android:screenOrientation="sensor"
       android:windowSoftInputMode="adjustResize"
       android:theme="主Activity的皮肤"
       android:exported="true">
       <intent-filter>
           <action android:name="android.intent.action.MAIN"/>
           <category android:name="android.intent.category.LAUNCHER"/>
       </intent-filter>
   </activity>

设置状态栏隐藏/显示的方法

双击应用的manifest.json文件,切换到“代码视图”,在apple节点下添加UIStatusBarStyle节点:

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

推荐阅读更多精彩内容