ios Xcode 中 @1x、@2x 和 @3x 的图像大小应该是多少?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30049544/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 05:53:34  来源:igfitidea点击:

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

iosxcodeuiimage

提问by user2053760

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

例如,我有一个100*100大小的图像视图或按钮,我想设置它的图像或backgroundImage使用本地.png文件。根据我的理解,我需要创建 3 组图像,即100*100for @1x200*200for @2x300*300for @3x。我不确定我的理解是否正确,有人可以帮忙吗?

回答by enadun

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

根据我的理解,如果图像大小是 100 * 100

@1x -> 100 * 100

@1x -> 100 * 100

@2x -> 200 * 200

@2x -> 200 * 200

@3x -> 300 * 300

@3x -> 300 * 300

enter image description here

在此处输入图片说明

There is something to understand. By creating 2xand 3ximages, 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.

有一点需要理解。通过创建2x3x图像,您不能期望每个 iPhone 屏幕的布局完全相同。布局将因屏幕而异。1x、2x 和 3x 图像尺寸仅处理屏幕的像素密度。

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

假设您有一个图像,320 * 70并且您正在创建

@1x -> 320 * 70

@1x -> 320 * 70

@2x -> 640 * 140

@2x -> 640 * 140

@3x -> 960 * 210

@3x -> 960 * 210

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

这将是您在不同屏幕上的输出。 在此处输入图片说明

回答by Rupal Patel

For @3ximage increase @1ximage size by 3 times!

对于@3x图像,将@1x图像大小增加3 倍!

e.g.

例如

15 x 15 = @1x

15 x 15 = @1x

30 x 30 = @2x

30 x 30 = @2x

45 x 45 = @3x

45 x 45 = @3x

OR

或者

100 x 100 = @1x

100 x 100 = @1x

200 x 200 = @2x

200 x 200 = @2x

300 x 300 = @3x

300 x 300 = @3x

OR

或者

15 x 10 = @1x

15 x 10 = @1x

30 x 20 = @2x

30 x 20 = @2x

45 x 30 = @3x

45 x 30 = @3x

I hope this is helpful to you!

我希望这对你有帮助!

回答by Nilesh Mahajan

Yes, your understanding is correct.

是的,你的理解是正确的。

A standard resolution image has a scale factor of 1.0 and is referred to as an @1x image. High resolution images have a scale factor of 2.0 or 3.0 and are referred to as @2x and @3x images. Suppose you have a standard resolution @1x image that's 100px × 100px, for example. The @2x version of this image would be 200px × 200px. The @3x version would be 300px × 300px.

标准分辨率图像的比例因子为 1.0,称为 @1x 图像。高分辨率图像的比例因子为 2.0 或 3.0,被称为@2x 和@3x 图像。例如,假设您有一个标准分辨率 @1x 图像,即 100px × 100px。此图像的 @2x 版本为 200px × 200px。@3x 版本将是 300px × 300px。

enter image description here

在此处输入图片说明

For more details you can check this link https://developer.apple.com/ios/human-interface-guidelines/graphics/image-size-and-resolution/

有关更多详细信息,您可以查看此链接 https://developer.apple.com/ios/human-interface-guidelines/graphics/image-size-and-resolution/

回答by Azat

Yes, you are right. But if you are using Assetsyou can do it all in one image with three slots for it

你是对的。但是,如果您正在使用Assets,则可以在一张图像中完成所有操作,其中包含三个插槽

回答by David 'mArm' Ansermot

Use the assets catalog. Xcode will manage the @1x, @2x, @3x easilly, and tell you the dimensions for the images.

使用资产目录。Xcode 将轻松管理@1x、@2x、@3x,并告诉您图像的尺寸。

With it it's easy to manage the AppIcon and LaunchScreen images.

使用它可以轻松管理 AppIcon 和 LaunchScreen 图像。