HarmonyOS 深色模式下,应用页面的时间、电量等信息展示?

如题:HarmonyOS 深色模式下,应用页面的时间、电量等信息展示?

阅读 517
1 个回答

深色模式下可以将状态栏的颜色修改一下

在onWindowStageCreate方法中,判断是否是深色模式,如果是的话,则使用以下代码:

windowStage.getMainWindow((e,w)=>{
  let t=w.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM);
  AppStorage.setOrCreate<window.AvoidArea>(eHomeApp.AVOID_AREA,t);

  let systemBarProperties: window.SystemBarProperties = {
    isStatusBarLightIcon: true,
    statusBarContentColor: '#ffffff'
  }
  w.setWindowSystemBarProperties(systemBarProperties)
})