【问题标题】:Get the iOS safe area width/height in Nativescript在 Nativescript 中获取 iOS 安全区域的宽度/高度
【发布时间】:2021-05-03 09:43:15
【问题描述】:

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

有人可以帮帮我吗?

【问题讨论】:

    标签: nativescript nativescript-vue


    【解决方案1】:

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

    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 环境中引发错误吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-05-19
    • 2018-03-31
    • 2013-01-15
    • 1970-01-01
    • 1970-01-01
    • 2011-08-06
    • 1970-01-01
    相关资源
    最近更新 更多