Xcode图像说明 [英] Xcode images explanation

查看:156
本文介绍了Xcode图像说明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是什么使图像1x,2x或3x(@ 1x,@ 2x,@ 3x)?如何制作3x图像?

What makes an image 1x, 2x or 3x (@1x, @2x, @3x)? How can you make a 3x image?

推荐答案

iOS在其坐标系中使用点而不是像素。在原始非视网膜设备(iPhone,iPhone3G,iPhone3GS,iPad,iPad 2,iPad mini和早期iPod触摸)中,坐标系中的一个点映射到设备屏幕上的一个像素。那时候,生活很简单,你提供了映射到点大小的应用程序的图像,一切看起来都很棒。

iOS uses points instead of pixels in its coordinate systems. In the original non-retina devices (iPhone, iPhone3G, iPhone3GS, iPad, iPad 2, iPad mini, and early iPod touches) one point in the coordinate system mapped to one pixel on the screen of the device. At that time, life was simple, you provided images to your app that mapped to the point size and everything looked great.

当Apple推出第一款视网膜显示设备时(iPhone) 4,iPad配有Retina显示屏和iPod touch 4),设备每个点都有2个像素。 Apple设计了一种巧妙的方法来解决这个问题。程序员只需要在程序中添加第二个图像并增加分辨率,并在名称上加上@ 2x。不需要更改代码。如果您的代码加载了一个名为house的图像,iOS将在非视网膜设备(例如iPad 2或原始iPad mini)上加载house,并且它将使用house @ 2x作为视网膜设备。 iPhone 6 Plus具有更高的分辨率,因此它使用@ 3x版本。

When Apple introduced the first retina display devices (iPhone 4, iPad with Retina Display, and iPod touch 4), the devices had 2 pixels for every point. Apple devised a clever way of dealing with this. The programmer just had to add a second image to their program with the increased resolution and add @2x to the name. No changes to the code were needed. If your code loads an image called "house", iOS will load "house" on a non-retina device (such as the iPad 2 or original iPad mini), and it will use "house@2x" for the retina devices. The iPhone 6 Plus has even higher resolution so it uses a @3x version.

那么是什么使图像@ 1x,@ 2x或@ 3x?如果你的房子图像是120像素乘90像素,那么你的house @ 2x图像应该是240 x 180像素,即每个维度中像素数的两倍(简称2x)。 house @ 3x版本应该是360 x 270(每个维度中像素数的3倍)。

So what makes an image @1x, @2x, or @3x? If your "house" image is 120 pixels by 90 pixels, then your "house@2x" image should be 240 by 180 pixels, that is twice the number of pixels in each dimension ("2x" for short). The "house@3x" version should be 360 by 270 (3 times the number of pixel in each dimension).

由你来确保@ 2x和@ 3x版本有更多的细节,而不仅仅是更多的像素。您可以使用 Photoshop Pixelmator 来创建您的图像。首先创建图像的非常详细的版本(@ 3x版本),然后将其缩小到@ 2x分辨率并将该版本保存为@ 2x版本。然后再次打开@ 3x版本并将其缩放到@ 1x分辨率并将其保存为@ 1x版本。 将所有三个版本添加到Xcode中的资产目录,iOS将为相应的设备加载适当的版本。

It's up to you to make sure that the @2x and @3x versions have more detail, and not just more pixels. You can use a program like Photoshop or Pixelmator to create your images. Start by creating the nice highly detailed version of your image (the @3x version), and then scale it down to the @2x resolution and save that version as your @2x version. Then open your @3x version again and scale it to the @1x resolution and save that as your @1x version. Add all three versions to the Assets Catalog in Xcode, and iOS will load the appropriate version for the appropriate devices.

这篇关于Xcode图像说明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆