简体   繁体   English

为什么UIScreen的大小是iPhone本身的一半(以像素为单位)?

[英]Why is the size of my UIScreen half the size of the iPhone itself(in pixels)?

So I have been programming in xCode, and I've found out where to position my SKSpriteNodes by printing my UIScreen.mainScreen().bounds.width/height . 因此,我一直在使用xCode进行编程,并且通过打印UIScreen.mainScreen().bounds.width/height来确定将SKSpriteNodes在哪里。 For the iPhone 6, it prints 667 by 375, however the iPhone itself actually is double that, 1334 x 750. Why is this? 对于iPhone 6,它的输出为667 x 375,但是iPhone本身实际上是它的两倍,是1334 x750。为什么?

This is because size in iOS is calculated in points . 这是因为iOS的大小是以点为单位计算的 Depending on your screen pixel density, either the scale is 1, 2, or 3. 根据您的屏幕像素密度, scale为1、2或3。

Since an iPhone 4 is double the resolution of iPhone 3G but the UI elements must stay the same size, the iPhone 4 is set at a scale of 2, so if you make a 50x50 square, it appears the same size on both devices even though the true dimensions of the iPhone 4 square is at 100x100. 由于iPhone 4的分辨率是iPhone 3G的两倍,但UI元素必须保持相同的大小,因此iPhone 4的scale设置为2,因此,如果您将其设置为50x50的正方形,即使两个设备上的尺寸都相同 iPhone 4正方形的真实尺寸为100x100。

iPhone 6 uses a scale of 2 and iPhone 6 Plus uses a scale of 3. The beauty of this system is that you don't have to manage the apparent sizes of objects ; iPhone 6的缩放比例为2,iPhone 6 Plus的scale为3。该系统的优点在于, 您不必管理对象的外观大小 if you set the dimensions to 50x50 points, it will stay generally the same size across all devices. 如果将尺寸设置为50x50点,则在所有设备上尺寸通常保持相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM