Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What should image sizes be at @1x, @2x and @3x in Xcode?

Tags:

xcode

ios

uiimage

For example, I have a 100*100 size imageview or button, and I want to set its image or backgroundImage with a local .png file. Based on my understanding, I need to create 3 sets of images, i.e. 100*100 for @1x, 200*200 for @2x, 300*300 for @3x. I am not sure if my understanding is correct or not, can anyone help?

like image 931
user2053760 Avatar asked May 05 '15 09:05

user2053760


People also ask

What is 1x 2x and 3x in IOS?

1x, 2x, and 3x images allow developers and Apple to optimize app presentation based on the user's device, whether an entry-level iPhone or the most expensive iPad. Conceptually, 1x, 2x, and 3x images are the same image -- simply at different sizes.

What are 1x and 2x images?

1x and 2x are just ways of defining an image that has a certain amount of pixel resolution. A 2x image has a higher resolution but has twice the width and height of a 1x image.

What size image is best for iPhone?

Your iPhone uses a ratio of 3:4 by default, which means that if you wanted to print a 3 x 4 photo or a 6 x 8 photo, you could do it without any cropping at all.

What is 1x scale?

Scale factors All platforms use a coordinates system based on measurements in points, which map to pixels in the display. A standard-resolution display has a 1:1 pixel density (also called @1x), where one pixel is equal to one point. High-resolution displays have a higher pixel density, such as 2:1 or 3:1.

What is the size of the login button image in Xcode?

For instance, if your app contains an image for the login button, Xcode expects you to supply three different sizes of the same button image. If the base size of the image is 100x100 pixels, then it should be 200x200 pixels at 2x and 300x300 pixels at 3x.

What is the difference between 1x 2x and 3x images?

Conceptually, 1x, 2x, and 3x images are the same image -- simply at different sizes. For instance, if your app contains an image for the login button, Xcode expects you to supply three different sizes of the same button image.

What are single scale resources in Xcode 12?

Up until Xcode 12, we were able to use single scale resources by using PDF assets. It takes away the need to generate individual images for each scale using the @1x, @2x, and @3x postfix. This saves you time and also takes away potential mistakes like accidentally generating a @3x asset with the @1x image size (we all did that once, right?).

How do I convert an app image to 1x or 2x?

Hotpot.ai created a free, easy icon resizer to convert an app image into the 1x, 2x, and 3x sizes expected by Xcode. This service works with both normal app images and app icons alike.


1 Answers

According to my understanding, if the image size is 100 * 100

@1x -> 100 * 100

@2x -> 200 * 200

@3x -> 300 * 300

enter image description here

There is something to understand. By creating 2x and 3x images, you can't expect exact same layout from each iPhone screen. The layout will be different from screen to screen. 1x, 2x and 3x image sizes dealing with only the pixel density of the screen.

Suppose you have an image which is 320 * 70 and you are creating

@1x -> 320 * 70

@2x -> 640 * 140

@3x -> 960 * 210

This will be your output in different screens. enter image description here

like image 57
enadun Avatar answered Oct 12 '22 10:10

enadun