跳转到内容

安全区域

获取安全区域信息(从 UserAgent 解析),用于适配刘海屏、全面屏等设备。

const safeArea = SuperSDK.getSafeArea();
console.log(safeArea);
// { top: 88, bottom: 34 }
// top: 状态栏高度(物理像素)
// bottom: 导航栏高度(物理像素)

返回值:

参数类型说明
topnumber状态栏安全区域高度(物理像素)
bottomnumber导航栏安全区域高度(物理像素)

注意:此方法为同步方法,直接返回结果。安全区域信息由客户端通过 UserAgent 注入(SafeAreaTop/xx SafeAreaBottom/xx),需要客户端调用 setSafeArea 或 fitSystemWindows 后才能获取到正确的值。