Brennan Adler
Brennan Adler

Reputation: 915

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. For the iPhone 6, it prints 667 by 375, however the iPhone itself actually is double that, 1334 x 750. Why is this?

Upvotes: 0

Views: 74

Answers (1)

Schemetrical
Schemetrical

Reputation: 5536

This is because size in iOS is calculated in points. Depending on your screen pixel density, either the scale is 1, 2, or 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 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; if you set the dimensions to 50x50 points, it will stay generally the same size across all devices.

Upvotes: 1

Related Questions