claassenApps claassenApps - 1 year ago 141
Swift Question

Understanding Image Size for Different Resolution Screens

I'm having a hard time putting all the information on image sizes for @1x, @2x, and @3x together. I've been using the scene editor in XCode with the scene size being 1334x750 (pixel dimensions of the screen of the iPhone 6). So when I size an image for a sprite in that scene, is that the size I should use for the @2x?

From what I've read in the documentation CGSize uses points, not pixels, so if I have an image that is CGSize(width: 50, height: 50), is this independent of my scene size in the scene editor?

Bottom line question: How does the CGSize dimensions translate to how I export my images for @1x, @2x, and @3x in pixels and what should the PPI be when I export?

Answer Source

The concept is simple. The size in Storyboard or Interface Builder should be the size of you asset in @1x format.

The retina display ( or the iPhone 6+ @3x size ) does not mean than you have much space than before, it means that you can draw 2 ( or 3 ) pixels where you draw 1 before.

So for a 50x50 px Image View, cou should have 3 assets : - Image@1x.png ( 50x50 px) - Image@2x.png ( 100x100 px) - Image@3x.png ( 150x150 px)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download