查看状态栏设置,全局搜索setWindowSystemBarProperties,发现对SystemBarProperties中的statusBarColor进行了设置,且值没有设置为透明色。
import { window } from '@kit.ArkUI';
import { common } from '@kit.AbilityKit';
@Entry
@Component
struct Index {
aboutToAppear(): void {
let context: common.UIAbilityContext = this.getUIContext().getHostContext() as common.UIAbilityContext;
window.getLastWindow(context).then((lastWindow) => {
let systemBarProperties: window.SystemBarProperties = {
statusBarColor: '#000000', // 状态栏背景色黑色
statusBarContentColor: '#ffffff' // 状态栏文字白色
};
lastWindow.setWindowSystemBarProperties(systemBarProperties); // 设置主窗口状态栏的属性
});
}
build() {
Column() {
Text('Hello World')
.width('100%')
.height('100%')
.fontColor(Color.White)
.fontSize(20)
.textAlign(TextAlign.Center);
}
.width('100%')
.height('100%')
.backgroundColor(Color.Black)
.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM]);
}
} import { window } from '@kit.ArkUI';
import { common } from '@kit.AbilityKit';
@Entry
@Component
struct Index {
aboutToAppear(): void {
let context: common.UIAbilityContext = this.getUIContext().getHostContext() as common.UIAbilityContext;
window.getLastWindow(context).then((lastWindow) => {
lastWindow.setWindowLayoutFullScreen(true);
let systemBarProperties: window.SystemBarProperties = {
statusBarColor: 'rgba(0, 0, 0, 0)', // 透明
statusBarContentColor: '#ffffff' // 状态栏文字白色
};
lastWindow.setWindowSystemBarProperties(systemBarProperties); // 设置主窗口状态栏的属性
});
}
build() {
Column() {
Text('Hello World')
.width('100%')
.height('100%')
.fontColor(Color.White)
.fontSize(20)
.textAlign(TextAlign.Center);
}
.width('100%')
.height('100%')
.backgroundColor(Color.Black)
.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP,SafeAreaEdge.BOTTOM]);
}
} 效果图如下:
