【问题标题】:Is there any way to get SIZE of the screen in tvOS?有没有办法在 tvOS 中获取屏幕的大小?
【发布时间】:2016-03-14 02:32:40
【问题描述】:

我正在尝试获取连接到 Apple tv 的屏幕大小,可以吗? 我一直在查看苹果提供的与 UIScreen 相关的文档,但除了与边界相同的 nativeBounds 之外找不到任何新内容。

let screenSize = UIScreen.mainScreen().bounds.size
let nativeBound = UIScreen.mainScreen().nativeBounds.size

它们都以像素为单位给我输出,但我也需要屏幕/显示器尺寸(英寸)。这样我就可以相应地安排显示。

提前致谢!

【问题讨论】:

    标签: swift size screen tvos tvos9.1


    【解决方案1】:

    首先,UIScreen.mainScreen().bounds 以点而不是像素为单位返回屏幕大小。见the docs

    UIScreen.mainScreen().nativeBounds 返回屏幕大小(以像素为单位)。

    要找到实际的屏幕尺寸(以绝对尺寸单位,例如英寸),您需要知道像素的物理尺寸,并将其乘以 nativeBounds

    但是,我认为 iOS 没有用于检索像素大小的 API。

    【讨论】:

    • 所以这就是我正在寻找的特定点 screenSizeInPixels 可以通过 let nativeBound = UIScreen.mainScreen().nativeBounds.size 找到。
    • 是的。 nativeBounds 以像素为单位返回大小,这样您就不用进行计算了。我会更新我的答案。
    猜你喜欢
    • 1970-01-01
    • 2020-01-05
    • 1970-01-01
    • 2017-04-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-19
    相关资源
    最近更新 更多