ios Xcode 6 - 用于通用图像支持的 xcassets
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26020979/
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
Xcode 6 - xcassets for universal image support
提问by aresz
Currently working on a universal SpriteKit project. I'll be supporting the following devices:
目前正在开发一个通用的 SpriteKit 项目。我将支持以下设备:
iPhone 4/s, iPhone 5/c/s, iPhone 6, iPhone 6+
iPhone 4/s、iPhone 5/c/s、iPhone 6、iPhone 6+
iPad non-ret, iPad retina
iPad 非视网膜,iPad 视网膜
I am confused on the iPhone part. I already have 4 versions for my background sprite for the 4 different screen resolutions of the iPhones. But which goes to which?
我对 iPhone 部分感到困惑。对于 iPhone 的 4 种不同屏幕分辨率,我的背景精灵已经有 4 个版本。但是哪个去哪个?
I know the 3x is for the 6+, and I think the 5/c/s goes to the Retina 4 2x, but I do not know where the iPhone4/s, and 6 go. Anyone know?
我知道 3x 是给 6+ 的,我认为 5/c/s 去 Retina 4 2x,但我不知道 iPhone4/s 和 6 去哪里。有人知道吗?
Side note, when I create a Launch Image inside my xcassets file, I am shown these options, which basically has all the device I am supporting. Just wondering why this is not also the case when creating an Image Set
旁注,当我在我的 xcassets 文件中创建启动图像时,我会看到这些选项,这些选项基本上包含我支持的所有设备。只是想知道为什么在创建图像集时情况并非如此
Also how do you guys approach creating images/sprites for a universal application? Now that the new iPhone 6, and 6 plus are out, I have 2 more resolutions to support which is still confusing for me as I'm still a beginner.
另外你们如何为通用应用程序创建图像/精灵?现在新的 iPhone 6 和 6 plus 已经出来了,我还有 2 个要支持的分辨率,这对我来说仍然很困惑,因为我仍然是一个初学者。
回答by Undo
This is a little confusing - here's how I understand it (this is in reference to the top image):
这有点令人困惑 - 这是我的理解(这是参考顶部图像):
1ximages are for the original iPhone through the 3GS - 'standard' resolution devices (3.5" screens)
2ximages are for the iPhone 4 and 4S (3.5" Retina screens) and are also used for the iPhone 6.
Retina 4 2xare for the iPhone 5 and 5s (4" Retina screens)
3ximages are for the new iPhone 6+ (5.5" super-Retina [3x] screen)
1x图像适用于通过 3GS 的原始 iPhone - “标准”分辨率设备(3.5 英寸屏幕)
2x图像适用于 iPhone 4 和 4S(3.5 英寸 Retina 屏幕),也适用于 iPhone 6。
Retina 4 2x适用于 iPhone 5 和 5s(4 英寸 Retina 屏幕)
3x图像适用于新 iPhone 6+(5.5 英寸超视网膜 [3x] 屏幕)
I believe that the iPhone 6 (4.7" screen) will use the Retina 4 2x images, but I would have to test it.
我相信 iPhone 6(4.7 英寸屏幕)将使用 Retina 4 2x 图像,但我必须对其进行测试。
Side note, when I create a Launch Image inside my xcassets file, I am shown these options, which basically has all the device I am supporting. Just wondering why this is not also the case when creating an Image Set
旁注,当我在我的 xcassets 文件中创建启动图像时,我会看到这些选项,这些选项基本上包含我支持的所有设备。只是想知道为什么在创建图像集时情况并非如此
If you compare the two images, the lower one has everything the upper one does, except for a 1x iPhone graphic. You don't need that if you're only supporting iOS 7 and above, since iOS 7 doesn't run on any non-Retina phone-form devices. To be honest, I don't understand why the top image has a 1x iPhone form graphic option - maybe because you checked the "iPhone" box in the sidebar?
如果您比较两张图片,除了一张 1x iPhone 图形外,下面一张拥有上面一张的所有内容。如果您只支持 iOS 7 及更高版本,则不需要它,因为 iOS 7 不能在任何非 Retina 手机形式的设备上运行。老实说,我不明白为什么顶部图像有一个 1x iPhone 表单图形选项 - 也许是因为您选中了侧边栏中的“iPhone”框?
Also how do you guys approach creating images/sprites for a universal application
还有你们如何为通用应用程序创建图像/精灵
For most non-fullscreen images (like a logo), you really only have 3resolutions to support - standard (1x), Retina (2x), and the iPhone 6+ (3x). These are simply different qualityof images, not really different sizes. So if you have a 10x10 image on a standard device, that would mean you need a 20x20 image on a Retina device and a 30x30 image on an iPhone 6+. On all devices, they would show up as a 10x10 image.
对于大多数非全屏图像(如徽标),您实际上只支持3 种分辨率 - 标准 (1x)、Retina (2x) 和 iPhone 6+ (3x)。这些只是不同质量的图像,而不是真正不同的尺寸。因此,如果您在标准设备上拥有 10x10 图像,则意味着您需要在 Retina 设备上使用 20x20 图像,在 iPhone 6+ 上使用 30x30 图像。在所有设备上,它们都会显示为 10x10 的图像。
A great tool I used for managing different resolutions of icons is iConify.
我用来管理不同分辨率图标的一个很好的工具是iConify。
I create them at the highest size I need (30x30 [@3x] for an image I want to be 10x10 on a device), then save it as a png and resize copies to 20x20 [@2x] and 10x10 [standard]. A bettersolution would be to create and use vector graphics, which would resize better to any size.
我以我需要的最大尺寸创建它们(30x30 [@3x] 对于我希望在设备上为 10x10 的图像),然后将其另存为 png 并将副本大小调整为 20x20 [@2x] 和 10x10 [标准]。一个更好的解决办法是创建和使用矢量图形,这将更好地调整到任何尺寸。
回答by Dhaivat Vyas
In 1x place image with resolution 320 x 480.
In 2x place image with resolution 640 x 960.
In Retina 4 2x place image with resolution 640 x 1136.
in 3x place image with resolution 1242 x 2208.
在分辨率为 320 x 480 的 1x 位置图像中。
在分辨率为 640 x 960 的
2x 位置图像中。在 Retina 4 中,分辨率为 640 x 1136 的 2x 位置图像。
在分辨率为 1242 x 2208 的 3x 位置图像中。
Images of Retina 4 2x will upscale to resolution 750 x 1334.
Images 3x will downscale to resolution 1080 x 1920.
Retina 4 2x 的图像将放大到 750 x 1334 的分辨率。
图像 3x 将缩小到 1080 x 1920 的分辨率。
You can also visit this links for launch screen images:
http://www.paintcodeapp.com/news/iphone-6-screens-demystified
http://www.paintcodeapp.com/news/ultimate-guide-to-iphone-resolutions
您还可以访问此链接以获取启动屏幕图像:
http://www.paintcodeapp.com/news/iphone-6-screens-demystified
http://www.paintcodeapp.com/news/ultimate-guide-to-iphone-决议
For all other images resolution and size:
https://developer.apple.com/ios/human-interface-guidelines/graphics/launch-screen/https://developer.apple.com/ios/human-interface-guidelines/graphics/image-size-and-resolution/https://developer.apple.com/ios/human-interface-guidelines/graphics/custom-icons/
对于所有其他图像分辨率和大小:
https:
//developer.apple.com/ios/human-interface-guidelines/graphics/launch-screen/ https://developer.apple.com/ios/human-interface-guidelines/图形/图像大小和分辨率/ https://developer.apple.com/ios/human-interface-guidelines/graphics/custom-icons/
How to use Image.xcassets:
https://www.youtube.com/watch?v=_36Y6rDcKP0&list=PLXCowKcXAVgrCe2Lezv0acRf4adQLshv2
如何使用 Image.xcassets:https: //www.youtube.com/watch?v =_36Y6rDcKP0 &list =PLXCowKcXAVgrCe2Lezv0acRf4adQLshv2
Hope this will be more helpful.
希望这会更有帮助。
回答by Lukas Kalinski
If you have your launch images in an xcasset file, you can do the following in Xcode 6.
如果您的启动图像在 xcasset 文件中,您可以在 Xcode 6 中执行以下操作。
Select the launch image asset, select a specific resolution (1x, 2x, Retina 4, etc) and open the attributes inspector (see image below).
选择启动图像资产,选择特定分辨率(1x、2x、Retina 4 等)并打开属性检查器(见下图)。
Under the "Image" section, you will have a "Expected Size" attribute.
在“图像”部分下,您将拥有“预期大小”属性。
回答by zeeawan
Inside images.xcassets, you can add different devices support by right clicking as shown in the snap
在images.xcassets中,您可以通过右键单击来添加不同的设备支持,如快照所示
Edit:Well, it doesn't seem working when I drag n drop images to placeholders. It gets messed up as shown next
编辑:好吧,当我将 n 个拖放图像拖到占位符时,它似乎不起作用。它变得一团糟,如下所示
I don't know why it is acting odd on my Xcode 6.4 though.
我不知道为什么它在我的 Xcode 6.4 上表现得很奇怪。
Edit#2:
编辑#2:
I see a bug from apple here. I can select 'Universal' along with any device upon right click as you can see in the first image above. But via attribute inspector I can correctly select either 'Universal' or specific devices as shown here
我在这里看到了一个来自苹果的错误。我可以在右键单击时选择“通用”和任何设备,如上图所示。但是通过属性检查器,我可以正确选择“通用”或特定设备,如下所示
Edit#3:
编辑#3:
In Xcode 7the attribute inspector has been changed and now it gives option same like the right click. So instead of either 'Universal' or specific devices, now it offers to select all.
在Xcode 7 中,属性检查器已更改,现在它提供与右键单击相同的选项。因此,现在它提供了全选,而不是“通用”或特定设备。
回答by NSSwift
There is one tool : AVXCassets Generatorwith which you can directly generate XCAssets file for all your icons and images just by one click.
有一个工具:AVXCassets Generator,您可以使用它直接为所有图标和图像生成 XCAssets 文件,只需单击一下。
hope you will like it.
希望你会喜欢。