swift - 如何找到 38 毫米或 42 毫米的苹果 watch ?

标签 swift watchkit apple-watch watchos-3

以编程方式找出 Apple Watch 是 38 毫米还是 42 毫米的正确方法是什么?我怎样才能为它创建一个结构对象来访问它,如下所示:

if watch.size == 38 { 
} else { 
}

最佳答案

您可以通过以下方式查看 Apple Watch 尺寸:-

public struct watch {

     public static var screenWidth: CGFloat {
          return WKInterfaceDevice.current().screenBounds.width
     }

     public static var is38: Bool {
          return screenWidth == 136
     }

     public static var is42: Bool {
          return screenWidth == 156
     }
}

关于swift - 如何找到 38 毫米或 42 毫米的苹果 watch ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42898085/

相关文章:

ios - 在模拟器中运行 Apple Watch glance 应用程序时出现问题

ios - Watchkit:以编程方式设置全局色调

ios - 带有复选框的交互式 TableView 标题

ios - 从代码中删除打印行

ios - 其 View 不在窗口层次结构中

swift - WatchKit (watchOS 2) CLLocationManager 返回零坐标

ios - 如何更改箭头以在 watchkit OS2 中返回

ios - tableview单元格子 ScrollView 不水平滚动

ios - 观看应用程序自定义菜单图像未显示?

ios - 将文本从 iOS 标签传递到 WatchOS 标签 - swift-