【发布时间】:2021-05-03 09:43:15
【问题描述】:
我正在尝试在 Nativescript 中获取 iOS 安全区域的宽度和高度。我找不到有关如何完成此操作的任何文档。
有人可以帮帮我吗?
【问题讨论】:
标签: nativescript nativescript-vue
我正在尝试在 Nativescript 中获取 iOS 安全区域的宽度和高度。我找不到有关如何完成此操作的任何文档。
有人可以帮帮我吗?
【问题讨论】:
标签: nativescript nativescript-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;
【讨论】:
application.ios 未定义,此代码会在android 环境中引发错误吗?