鸿蒙沉浸式导航栏封装

import { window } from ‘@kit.ArkUI’
import { BreakpointConstants } from ‘…/…/common/utils/BreakpointConstants’;
import { getScreenWith } from ‘…/…/common/utils/CmtSystemTool’
import myNavigation from ‘…/…/common/view/navigationBar’;

@Entry
@Component
export struct statel {
@StorageLink(‘currentBreakpoint’) @Watch(‘onBreakpointChange’) currentBreakpoint: string =
BreakpointConstants.BREAKPOINT_SM;
@StorageProp(‘currentOrientation’) @Watch(‘onBreakpointChange’) currentOrientation: window.Orientation = window.Orientation.UNSPECIFIED

onBreakpointChange() {
getScreenWith()//实时获取屏幕尺寸
}

aboutToAppear(): void {
}

aboutToDisappear(): void {

}

onPageHide(): void {
this.commonNavColor()
}

onPageShow(): void {

  this.mineNavColor()

}

mineNavColor() {
// 获取当前应用窗口
let windowClass = AppStorage.get<window.Window>(‘windowClass’) as window.Window;
// 将状态栏和导航栏的背景色设置为跟应用窗口相同的颜色
windowClass.setWindowSystemBarProperties({
// 颜色属性为ARGB,将蒙尘设置为0%使其透明
// 导航栏颜色
navigationBarColor: ‘#ffffff’,
// 状态栏颜色
statusBarColor: ‘#41A09A’,
// 状态栏文字颜色
statusBarContentColor: ‘#ffffff’
})
}

commonNavColor() {
// // 获取当前应用窗口
let windowClass = AppStorage.get<window.Window>(‘windowClass’) as window.Window;
// 将状态栏和导航栏的背景色设置为跟应用窗口相同的颜色
windowClass.setWindowSystemBarProperties({
// 颜色属性为ARGB,将蒙尘设置为0%使其透明
// 导航栏颜色
navigationBarColor: ‘#ffffff’,
// 状态栏颜色
statusBarColor: ‘#ffffff’,
// 状态栏文字颜色
statusBarContentColor: ‘#ffffff’
})
}

//首页构建tab
build() {
}
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值