#鸿蒙学习大百科#如何实现页面的实现沉浸式效果?

如何实现页面的实现沉浸式效果?

HarmonyOS
2024-10-22 09:20:33
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
风间爱小新V
onWindowStageCreate(windowStage: window.WindowStage): void {

  windowStage.loadContent('pages/Index', (err) => {
    if (err.code) {
      hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
      return;
    }
    hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
  });

  // 1.获取应用主窗口。
  let windowClass: window.Window | null = null;
  windowStage.getMainWindow().then((data: window.Window) => {
    windowClass = data;
    // 2.实现沉浸式效果。
    let names: Array<'status' | 'navigation'> = [];
    windowClass.setWindowSystemBarEnable(names, (err: BusinessError) => {
      let errCode: number = err.code;
      if (errCode) {
        console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err));
        return;
      }
      console.info('Succeeded in setting the system bar to be visible.');
    });
  })
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
分享
微博
QQ
微信
回复
2024-10-22 22:06:55
相关问题
#鸿蒙学习大百科#如何实现ui优化?
1023浏览 • 1回复 待解决