修改页面状态栏颜色,以及沉浸式状态属性设置

修改页面状态栏颜色,以及沉浸式状态属性设置

HarmonyOS
2024-01-31 09:13:49
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
mislrb

参考代码

onWindowStageCreate(windowStage: window.WindowStage): void { 
  windowStage.getMainWindow((err, data) => { 
    if (err.code) { 
      return 
    } 
    GlobalThis.getInstance().setObject("mainWindow",data); 
    // 设置全屏展示,沉浸式 
    data.setWindowLayoutFullScreen(true); 
    let sysBarProps = { 
      statusBarColor: '#00000000', 
      navigationBarColor: '#00000000', 
      // 以下两个属性从API Version 8开始支持A03d00/JSAPP 
      // statusBarContentColor: '#2B3141', 
      // navigationBarContentColor: '#2B3141' 
    } as SystemBarPropertiesType; 
    data.setWindowSystemBarProperties(sysBarProps) 
    // 获取状态栏高度 
    let avoidArea = data.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM); 
    LogUtil.info("statusBarHeight===", avoidArea.topRect.height.toString()) 
    AppStorage.setOrCreate<number>("statusBarHeight", px2vp(avoidArea.topRect.height)) 
    // GlobalThis.getInstance().setObject("statusBarHeight", px2vp(avoidArea.topRect.height)) 
  }) 
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
分享
微博
QQ
微信
回复
2024-02-01 16:59:34
相关问题
如何设置沉浸状态栏
3507浏览 • 1回复 待解决
HarmonyOS 沉浸状态栏
656浏览 • 1回复 待解决
HarmonyOS 沉浸状态栏无效
515浏览 • 1回复 待解决
HarmonyOS 沉浸状态栏实现
709浏览 • 1回复 待解决
如何实现沉浸状态栏
1388浏览 • 1回复 待解决
HarmonyOS 沉浸状态栏最佳实践
823浏览 • 1回复 待解决
鸿蒙怎么 修改状态栏字体颜色
13310浏览 • 1回复 待解决
HarmonyOS 修改状态栏颜色不生效
1021浏览 • 1回复 待解决
HarmonyOS 状态栏颜色如何修改
1282浏览 • 1回复 待解决
HarmonyOS 状态栏怎么设置颜色
803浏览 • 1回复 待解决
HarmonyOS 动态设置状态栏颜色
812浏览 • 1回复 待解决
HarmonyOS 状态栏图标颜色设置
893浏览 • 1回复 待解决
HarmonyOS 如何设置状态栏颜色
944浏览 • 1回复 待解决