openharmony:systemui 状态栏导航栏颜色变化逻辑

陈浩南xxx
发布于 2023-10-10 11:02
浏览
0收藏

openharmony:systemui 状态栏导航栏颜色变化逻辑-鸿蒙开发者社区

一句话总结:windiw监听systemBarTintChange 收到回调,通知控件各自根据值动态改变颜色

文字虽简短,可以给开发系统应用的小伙伴快速打开开发思路

补充:应用改变导航栏和状态栏颜色方法
export default class EntryAbility extends UIAbility {}
—》 onWindowStageCreate(windowStage: window.WindowStage) {}

  // 获取主窗口。
    window.getLastWindow(this.context,(err, data) => {
      if (err.code) {
        console.error('Failed to get the subWindow. Cause: ' + JSON.stringify(err));
        return;
      }
      console.info('Succeeded in getting subWindow. Data: ' + JSON.stringify(data));
      let  mainWindowClass = data;
      let sysBarProps = {
        statusBarColor: '#ff00ff',
        navigationBarColor: '#00ff00',
        // 以下两个属性从API Version8开始支持。
        statusBarContentColor: '#ff0000',
        navigationBarContentColor: '#ff0000'
      };
      mainWindowClass.setWindowSystemBarProperties(sysBarProps, (err) => {
        if (err.code) {
          console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err));
          return;
        }
        console.info('Succeeded in setting the system bar properties.');
      });
}  
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.

标签
已于2023-10-10 11:17:32修改
1
收藏
回复
举报
1


回复
    相关推荐