iPhone的图像背景文件 [英] image background files for iPhones

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

问题描述

我们有一个应用程序的背景图片,对于运行该应用程序的每个设备,背景图片必须全屏显示.我们的问题是背景图像正在iPhone 6S +上平铺(显示缩小).

We have a background image for our app that needs to be full screen for each device we run the app on. Our problem is the background image is tiling on our iPhone 6S+ (Display Zoom off).

我用红线画出了平铺发生的地方...

I have drawn in red lines to highlight where the tiling is occurring...

我们创建了3个以下尺寸的背景图片...

We have created 3 background images of the following sizes...

因此,为1x设计(这是推荐的方式),我们的基本级1x背景图像的宽度为320像素.我们的2倍是640像素,我们的3倍是960像素.

So, designing for 1x (which is the recommended way to go), our base level 1x background image is 320 pixels wide. Our 2x is 640 pixels, and our 3x is 960 pixels.

问题在于iPhone 6S +的宽度为1080像素,根据此图表,您需要从3x的图像开始,该图像的宽度为1242像素.这就是我想念它应该如何工作的地方.

The problem is the iPhone 6S+ is 1080 pixels wide and according to this chart, you need to start with a 3x image that is 1242 pixels wide. And this is where I am missing how this is supposed to work.

来自

牢记以上图表,似乎您需要为每个分辨率使用单独的图像,并在上面的图像中用红色正方形突出显示.这样对吗?如果是的话,如何标记每个单独的图像,以便在运行时选择正确的图像?

With the above chart in mind, it seems you need a separate image for each resolution highlighted with a red square in the above image. Is this correct? And if yes, how do you label each individual image so that at runtime the correct one is picked?

推荐答案

您只需要三张图像,它们以 background.png 的名字命名.

Three images, named as you have them for background.png, are all you need.

现在让我们谈谈图像视图.他们使用 内容模式 显示图像.关键是选择正确的模式.Aspect Fill是您可能需要的,因为它将填充图像视图而不会扭曲图像.

Now let's talk about image views. They display their image using a content mode. The key thing is to pick the correct mode. Aspect Fill is what you probably want here, because it will fill the image view without distorting the image.

然后,一个步骤是使用比您现有的图像大的图像,并将显示该图像的图像视图配置为使用适当的内容模式(例如纵横比填充),以便缩小图像尺寸以适合(或,以节省内存,您可以在运行时自行调整大小).

One procedure, then, is to use a bigger image than what you have, and configure the image view that shows the image to use an appropriate content mode such as Aspect Fill, so that it sizes the image down to fit (or, to save memory, at runtime you can size it down yourself).

另一种可能性是保持图像原样,并通过告诉图像视图调整图像大小 up 使其适合,再在Plus机器上解决该问题,同样可以使用Aspect Fill.这看起来可能可接受或不可接受;您必须尝试一下,看看您的想法.

The other possibility would be to leave your image as it is, and solve the issue on the Plus machines by telling the image view to size the image up to fit, again possibly by using Aspect Fill. That might or might not look acceptable; you'd have to try it and see what you think.

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

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