uniapp 兼容IOS手机底部黑线 IOS苹果手机有很多款手机底部都有一条黑线。底部的tabbar 导航栏如果遇到IOS手机则会出现问题。 因为我这边的tabbar导航栏是自己写的,不是用的uniapp自带的,所以如果遇到IOS手机底部有黑线的这种,需要将tabbar导航栏的高度调整一下才可以。 除此之外还有些页面,底部有个按钮之类的,也是需要做兼容处理的。

uni-app:iPhone的底部安全区域
padding-bottom: constant(safe-area-inset-bottom);
padding-bottom: env(safe-area-inset-bottom);
uni.getSysteminfo({
success: res => {
let safeArea = res.safeAreaInsets.bottom;
}
})
该APi返回一个对象,包含 top right bottom left width height,其中bottom为安全区域高度
对应的兼容情况如下,uni-app的版本2.5.3+使用safeAreaInsets值
safeArea 在竖屏正方向下的安全区域 App、H5、微信小程序
safeAreaInsets 在竖屏正方向下的安全区域插入位置(2.5.3+) App、H5、微信小程序

uniapp自定义tabBar方案
一、pa

文章主要讨论了在uniapp开发中遇到的iOS设备底部出现黑线的问题,以及如何通过设置`padding-bottom:constant(safe-area-inset-bottom)`和`padding-bottom:env(safe-area-inset-bottom)`来解决这个问题。同时,文章提供了自定义tabBar的方案,包括在pages.json中配置,隐藏原生tabBar,创建自定义组件,并应用safe-area-inset-bottom进行兼容性适配。
最低0.47元/天 解锁文章
777

被折叠的 条评论
为什么被折叠?



