状态栏设置颜色失效?

如题:状态栏设置颜色失效?

问题代码

setStatusBarColor\(this.localSetting.isNight ? ‘\#f00’ : ‘\#f00’\)
阅读 180
1 个回答
/**
 * 设置状态栏颜色
 * @param color
 */
export function setStatusBarColor(color: string) {
  let windowClass: window.Window | undefined = undefined;
  try {
    let promise = window.getLastWindow(getContext());
    promise.then((data) => {
      windowClass = data;
      windowClass.setWindowSystemBarProperties({ statusBarColor: color, statusBarContentColor: color,
        navigationBarColor: color, navigationBarContentColor: color })
      console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
    }).catch((err: BusinessError) => {
      console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
    });
  } catch (exception) {
    console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(exception));
  }
}

将颜色设置改位6位的模式,比如红色改“\#ff0000”

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进