在HarmonyOS NEXT开发中状态栏怎么设置颜色?

在HarmonyOS NEXT开发中状态栏怎么设置颜色?状态栏要设置成红色,怎么设置?

阅读 739
1 个回答

参考demo:

let sysBarProps: window.SystemBarProperties = { 
  statusBarColor: '#ff00ff', 
}; 
 
let windowClass: window.Window = this.windowStage.getMainWindowSync(); // 获取应用主窗口 
 
windowClass.setWindowSystemBarProperties(sysBarProps, (err: BusinessError) => { 
  let errCode: number = err.code; 
  if (errCode) { 
    console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err)); 
    return; 
  } 
  console.info('Succeeded in setting the system bar properties.'); 
}); 
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进