Apple Watch:如何知道屏幕尺寸?

Abh*_*edi 10 apple-watch

我想了解我们如何知道苹果手表是38毫米还是42毫米,以便我可以编程设置UI元素的图像.

Abh*_*edi 20

我在WKInterfaceDevice课堂上想出来了

NSLog(@"%@", CGRectCreateDictionaryRepresentation([WKInterfaceDevice currentDevice].screenBounds));
Run Code Online (Sandbox Code Playgroud)

42毫米 {高度= 195; 宽度= 156; X = 0; Y = 0; }

38毫米 {高度= 170; 宽度= 136; X = 0; Y = 0; }

  • 在Swift中,您使用WKInterfaceDevice.currentDevice().screenBounds获得相同的效果. (3认同)