小程序获取手机状态栏高度
获取高度
let res = uni.getSystemInfoSync();
res.statusBarHeight即为状态栏高度
使用
获取状态栏高度为单位为px,小程序中一般使用rpx,这里可以做转换处理。
res = (res.statusBarHeight + 44)/(uni.upx2px(res.statusBarHeight + 44)/(res.statusBarHeight + 44))
这里默认自定义导航栏高度为44,可自行定义。若使用吸顶操作,res即为吸顶距离。