xcode 将所有图像放入资产目录?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18997319/
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
Put All Images in Asset Catalog?
提问by ma11hew28
I started a new project in Xcode 5.
我在 Xcode 5 中开始了一个新项目。
What is this
Images.xcassets
shenanigans?Am I supposed to put the various images I'm using for my app (like button images & stuff) in there or only the
AppIcon
&LaunchImage
?I see I can create a new folder in
Images.xcassets
. Should I create a folder called "Button Icons" or whatever and just throw them in there?See, but I just want to add some retina images to my target.
I'm only supporting iOS 7. So, I don't need to worry about other formats like non-retina.
Why did they make this so complicated and not document it at all? Why do I need these extra
Contents.json
files?It looks like I can uncheck (remove)
Images.xcassets
from the target but not the individual image files within the asset catalog.Can I just do things the old way or would I be missing out on compression/performance enhancements?
Is there a setting I can set so that my app treats all image files as retina images even if they dont have the
@2x
suffix in their filename?
这是什么
Images.xcassets
恶作剧?我应该把我用于我的应用程序的各种图像(如按钮图像和东西)放在那里还是只放
AppIcon
&LaunchImage
?我看到我可以在
Images.xcassets
. 我应该创建一个名为“按钮图标”或其他什么的文件夹,然后把它们扔进去吗?看,但我只想向我的目标添加一些视网膜图像。
我只支持 iOS 7。所以,我不需要担心其他格式,比如非视网膜。
为什么他们把这弄得如此复杂,而根本没有记录下来?为什么我需要这些额外的
Contents.json
文件?看起来我可以取消选中(删除)
Images.xcassets
目标,但不能取消选中(删除)资产目录中的单个图像文件。我可以用旧的方式做事还是会错过压缩/性能增强?
是否有我可以设置的设置,以便我的应用程序将所有图像文件视为视网膜图像,即使它们
@2x
的文件名中没有后缀?
回答by ma11hew28
In the "What's New in Xcode 5" WWDC 2013 Session Video, the speaker says
Image.xcassets
"collects all of your image-based resources, such as your launch images, icons, loose images that you use in your project, together into one place.""Also, Xcode knows about new iOS 7 APIs and so can even optimize the loading of your image-based resources." I'm assuming "it does it for you automatically" as long as you put your images in
Image.xcassets
(or another asset catalog included in your target).So, I suggest you suck it up, and adapt or die.
I don't know.
在“Xcode 5 中的新功能”WWDC 2013 会议视频中,演讲者说
Image.xcassets
“将您所有基于图像的资源,例如您在项目中使用的启动图像、图标、松散图像收集到一个地方。”“此外,Xcode 了解新的 iOS 7 API,因此甚至可以优化基于图像的资源的加载。” 只要您将图像放入
Image.xcassets
(或包含在目标中的其他资产目录),我就假设“它会自动为您执行此操作” 。所以,我建议你接受它,要么适应,要么死。
我不知道。
回答by xdeleon
There are not retina devices that are still supported by iOS 7 such as iPad mini and iPhone 3GS. Keep that in mind. The images will scale down and still work but I wanted to make sure you knew iOS 7 supported not retina devices.
没有 iOS 7 仍然支持的视网膜设备,例如 iPad mini 和 iPhone 3GS。记在脑子里。图像将按比例缩小并仍然有效,但我想确保您知道 iOS 7 不支持视网膜设备。
When you ask for an image by name iOS will look for the image by name. For example, "background.png" if there is a retina image "[email protected]" and the device is retina iOS will handle that for you. If you only plan on providing retina images there is nothing wrong with making the images all retina and excluding the "@2x" info in the image. name.
当您按名称请求图像时,iOS 将按名称查找图像。例如,“background.png”如果有一个视网膜图像“[email protected]”并且设备是视网膜 iOS 会为你处理。如果您只打算提供视网膜图像,那么使图像全部为视网膜并排除图像中的“@2x”信息并没有错。姓名。