首页 > 解决方案 > 在 Nativescript 中获取 iOS 安全区域的宽度/高度

问题描述

我正在尝试在 Nativescript 中获取 iOS 安全区域的宽度和高度。我找不到有关如何完成此操作的任何文档。

有人可以帮我吗?

标签: nativescriptnativescript-vue

解决方案


我已经找到了解决方案。我希望这对某人有所帮助。

import * as application from "@nativescript/core/application";
import { Screen } from "@nativescript/core/platform";

let screenheight = Screen.mainScreen.heightDIPs;
let safeAreaTopInset = application.ios.window.safeAreaInsets.top;
let safeAreaBottomInset = application.ios.window.safeAreaInsets.bottom;

let safeAreaHeight = screenheight - safeAreaTopInset - safeAreaBottomInset;

推荐阅读