本文介绍了如果我使用iPad尺寸创建应用程序,如何找到iPhone尺寸的“安全区域”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一款游戏并希望使用iPad尺寸设置(横向:1024x768)。据我所知,使用iPad设置只会在iPhone上裁剪掉部分高度。假设iPad(1024x768)有2048x1536背景图像,iPhone 6+(736x414)有2208x1242图像,

I am creating a game and want to use the iPad size settings (landscape: 1024x768). From what I've learnt, using the iPad settings will crop out part of the height only on an iPhone. Say I have a 2048x1536 background image for iPad (1024x768) and a 2208x1242 image for iPhone 6+ (736x414),

i。我如何确定iPad上的安全区域,它将以点和像素方式显示在iPhone 6+上?

i. how can I determine the 'safe region' from the iPad that will appear on the iPhone 6+ both point and pixel wise?

ii。 iPhone 6+的安全区域是否与带有1334x750图像的iPhone 6(667x375)相同?如果没有,那么如何同时确定点和像素呢?

ii. will the 'safe region' for the iPhone 6+ be the same as the iPhone 6 (667x375) with a 1334x750 image? If not, how can it also be determined both point and pixel wise?

推荐答案

我假设您希望创建一个可在iPad和iPhone上运行的通用游戏。如果是这种情况,在Attributes Inspector中定义图形资源时有两种可能的方法(选择Assets.xcassets时,Xcode界面的最右侧)。在设备部分,您可以选择通用,iPhone,iPad,Apple Watch,Apple TV,Mac以及它们的任意组合。

I assume you wish to create a universal game that runs both on iPad and iPhone. If that's the case, there are two possible approaches when defining your graphics assets in the Attributes Inspector (far right on your Xcode interface while Assets.xcassets is selected). In the Devices section, you can select among Universal, iPhone, iPad, Apple Watch, Apple TV, Mac and any combination of those.


  1. 如果您只选择通用,则必须确保您在iPhone和iPad上插入的资产看起来都不错。如果是这种情况,请参阅下面的一些提示,了解如何使您的资产安全地普遍使用。

  1. If you select "Universal" only, then you will have to make sure that the assets you insert there will look good both on iPhone and iPad. If that's the case, see below some hints of how to make your assets safe for using universally.

如果选择iPad和iPhone,必须包含适用于iPad和iPhone的独立资产,以及适当的分辨率和宽高比。在我过去的经历中,我总是以这种方式领导。对于iPad(1x),您必须提供1024x768背景,对于iPad(2x),您必须提供2048x1536,除非您选择单一比例并使用单个矢量PDF文件。分别对于iPhone来说,你必须提供480x320(1x,仅在你需要支持iPhone 3G / 3GS等旧设备的情况下,鉴于Sprite-Kit与iOS7一起推出的情况不太可能),然后是1334x750(2x) )和2208x1242(3x,适用于iPhone 6 +,6S +,7 +)。使用这种方法,您无需担心安全区域,因为您提供的图形将在每个设备上正确使用而不会从边缘切割。请记住,iPhone 4S和iPhone 5 / 5S / SE需要一些背景缩放才能使整个2x图像适合屏幕。否则它会放大。

If you select "iPad" and "iPhone", you will have to include separate assets for iPad and iPhone, with their appropriate resolutions and aspect ratios. In my past experience, I've always headed this way. For the iPad (1x) you will have to provide a 1024x768 background, for the iPad (2x) you will have to provide a 2048x1536, unless you choose "Single Scale" and use a single vector PDF file. Respectively, for the iPhone, you will have to provide a 480x320 (1x, only in case you need to support old devices such as iPhone 3G/3GS, quite unlikely given the fact Sprite-Kit was introduced with iOS7), then 1334x750 (2x), and 2208x1242 (3x, for the iPhone 6+, 6S+, 7+). With this approach you don't need to worry about "safe" zones, as the graphics you supply will be used on each device properly with no "cutting" off the edge. Just bear in mind that iPhone 4S and iPhone 5/5S/SE would need some background scaling in order to fit the whole 2x picture on the screen. Otherwise it would look zoomed in.

如果你采用第一种方法,那么你应该考虑以下信息:为了让您的通用图形安全地用于所有设备:
iPhone 5 / 5S / SE ......并且所有更新的显示器都具有16:9的显示宽高比。
iPhone 4S的宽高比为3:2(如果您的游戏支持iOS 9,您只会担心这一点)。
iPad屏幕宽高比为4:3。

If you go with the first approach, then you should consider the following information in order to make your "universal" graphics safe for use with all devices:iPhone 5/5S/SE...and all newer have a 16:9 display aspect ratio.iPhone 4S has 3:2 aspect ratio (you only worry about that if your game will support iOS 9).iPad screen aspect ratio is 4:3.

考虑到上述因素,您可以选择两条路径:
1.使用16 :9款通用资产,其左/右部分将在iPad和iPhone 4S上切断。
2.使用4:3通用资产,将其iPhone的上/下部分切断。

With the above in mind, there are two paths you could go:1. Use 16:9 universal assets that will have their left/right parts cut off on iPad and iPhone 4S.2. Use 4:3 universal assets that will have their upper/lower parts cut off on iPhones.

以上内容适用于您的2x资产,因为这些将可用于视网膜iPad和视网膜iPhone(4S,5 / 5S,SE,6 / 6S / 7)。

The above applies to your 2x assets as these will be used for both retina iPads and retina iPhones (4S, 5/5S, SE, 6/6S/7).

1x资产仅用于非视网膜iPad(iPad 2以防你支持iOS 9,否则也会跳过这些)。

1x assets will only be used for non-retina iPads (iPad 2 in case you would support iOS 9, otherwise skip these too).

3x资产只会用于PlusiPhone型号。所以我建议你只提供16:9的比例(2208x1242)。

3x assets will only be used for the "Plus" iPhone models. So I suggest you provide these in 16:9 ratio (2208x1242) only.

那么,你如何计算你的安全区域。非常简单:

So, how do you calculate your "safe" zones. Pretty straightforward:

案例1(16:9资产也用于iPad):身高1536(这是视网膜iPad的高度,以像素为单位,尽管如果你愿意在iPad Pro 12.9上完全像素完美,那么你应该增加到2048),宽度= 1536 * 16/9 = 2732像素宽(对于iPad Pro支持3640像素)。请注意,你必须在运行中缩小它 - 时间以适应iPhone。为了避免切断背景中的重要内容,请不要在2732x1536通用图像的中间2048像素的左侧或右侧放置任何内容(342像素危险区域如果你使用3640x2048图像(支持iPad Pro 12.9),那么只使用中间的2732像素,只留下454像素宽的左右边界中不重要的东西。

Case 1 (16:9 assets to be used for iPad too): height 1536 (this is the retina iPad height in pixels, although if you wish to be pixel-perfect on iPad Pro 12.9" then you should increase that to 2048), width = 1536 * 16 / 9 = 2732 pixels wide (3640 pixels for iPad Pro support). Note that you will have to scale it down in run-time in order to fit for the iPhones. In order to avoid cutting off important content from your background, don't put anything to the left or right of the middle 2048 pixels of the 2732x1536 universal image (342 pixel "danger" zones on the left and right). If you go with a 3640x2048 image (supporting iPad Pro 12.9"), then only use the middle 2732 pixels, leaving only unimportant stuff in the 454-pixel-wide left and right boundaries.

案例1b(与上面相同,但图像较小):另一种方法是使用原生(iPhone 6 / 6S / 7)1334/750像素图像,但是你必须扩大iPad规模,并缩小iPhone 4S / 5 / 5S / SE的尺寸。在这种情况下,您的安全区域为1000x750(在4:3 iPad和16:9 iPhone上均可见)。

Case 1b (same as above but with a smaller image): Another approach would be to use a native (iPhone 6/6S/7) 1334/750 pixels image, but then you will have to scale up for iPads, and scale down for iPhone 4S/5/5S/SE. In this case, your "safe" zone is 1000x750 (visible both on 4:3 iPads and 16:9 iPhones).

案例2(4:3资产为也用于iPhone):对于2x资产,使用2048x1536像素图像。根据您将精灵放置在屏幕上的方式,上部和/或下部会有损失。如果它居中,则您的安全区域为2048/16 * 9 = 1152,这导致2048x1552位于2048x1536资产中间。

Case 2 (4:3 assets to be used for iPhones too): For the 2x assets use 2048x1536 pixel images. Depending on how you position the sprite on the screen there will be loses on the upper and/or lower parts. If it's centered, then your "safe" zone is 2048 / 16 * 9 = 1152, which leads to 2048x1152 in the middle of the 2048x1536 asset.

如果您需要任何进一步说明我将很乐意详细说明。

If you need any further clarification I will be happy to elaborate.

这篇关于如果我使用iPad尺寸创建应用程序,如何找到iPhone尺寸的“安全区域”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 22:16