写点什么

鸿蒙 Next 动态修改状态栏背景色和字体颜色

作者:auhgnixgnahz
  • 2025-06-23
    北京
  • 本文字数:285 字

    阅读完需:约 1 分钟

定义一个全局的修改状态栏的方法,只需要传入想要修改的色值即可,也可以定义全局的状态模式,直接调用,根据业务需求自定义。


export const  bgcolors:string[]=['#faebd7','#00ffff','#7fffd4','#f5f5dc','#ffe4c4'];export const textColors:string[]=['#0000ff','#8a2be2','#a52a2a','#008b8b','#6495ed'];export function  changeStatusBarColor(barColor:string,contentColor:string){  window.getLastWindow(getContext(),(_err,win)=>  {    win.setWindowSystemBarProperties({      statusBarColor:barColor, //背景      statusBarContentColor:contentColor, //内容 文字 图标    });  })}
复制代码



发布于: 刚刚阅读数: 3
用户头像

auhgnixgnahz

关注

还未添加个人签名 2018-07-10 加入

还未添加个人简介

评论

发布
暂无评论
鸿蒙Next动态修改状态栏背景色和字体颜色_鸿蒙Next_auhgnixgnahz_InfoQ写作社区