小程序自定义导航栏高度计算
【代码】小程序自定义导航栏高度计算。
·
getTopHeiht(){
// 状态栏高度
let statusBarHeight = uni.getSystemInfoSync().statusBarHeight;
// #ifdef MP-WEIXIN
// 获取微信胶囊的位置信息 width,height,top,right,left,bottom
const custom = wx.getMenuButtonBoundingClientRect();
// logo位置 = 胶囊位置 - ((logo高 - 胶囊高) / 2) + 外框的padding
this.top_height = custom.top - ((50 - custom.height) / 2) - 12;
// 导航栏高度(标题栏高度) = 胶囊高度 + (顶部距离 - 状态栏高度) * 2
// this.top_height = custom.top - custom.top / 2;
// let navigationBarHeight1 = custom.height + (custom.top - this.statusBarHeight) * 2;
// 胶囊高度
// let navigationBarHeight = custom.height;
// let jnWidth = custom.width;
// let jnTop = custom.top;
// let nRight = custom.right;
// let jnBottom = custom.bottom,
// jnHeight = custom.height;
// let jnLeft = custom.left;
// 总体高度 = 状态栏高度 + 导航栏高度
// this.navHeight = this.navigationBarHeight + this.statusBarHeight;
// #endif
}

DAMO开发者矩阵,由阿里巴巴达摩院和中国互联网协会联合发起,致力于探讨最前沿的技术趋势与应用成果,搭建高质量的交流与分享平台,推动技术创新与产业应用链接,围绕“人工智能与新型计算”构建开放共享的开发者生态。
更多推荐
所有评论(0)