在 Xcode 中将“AppIcon”添加到项目的最有效方法?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32956985/
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
The most efficient way of adding "AppIcon" to project in Xcode?
提问by Adrian
Im programming an app in xcode and something has recently come to my attention when designing app icons. Here is the current setup that I have in my project:
我在 xcode 中编写了一个应用程序,最近在设计应用程序图标时引起了我的注意。这是我在项目中的当前设置:
Right now I have a 87x87pixel image for the "29pt" option (far left of the image), I also have a 120x120 for the 40pt option(middle) and I have a 180x180 pixel png for the 60pt option(far right). This seems highly inefficient, not only this but I need to supply @2 resolution images too? Surely there is a better way of doing this?
现在我有一个 87x87 像素的图像用于“29pt”选项(图像的最左侧),我还有一个 120x120 的图像用于 40pt 选项(中间),我有一个 180x180 像素的 png 用于 60pt 选项(最右侧)。这似乎非常低效,不仅如此,而且我还需要提供@2 分辨率的图像?当然有更好的方法来做到这一点吗?
回答by Adrian
There are a couple of approaches I've taken in the past. One way is to create your icons, etc. in GIMP, Photoshop, etc. If you need to resize them, there's a command line utility called ImageMagickwhich I find to be a lot easier for resizing images than setting sizes in an image editor. The command you would use for resizing is called mogrify
.
我过去采取了几种方法。一种方法是在 GIMP、Photoshop 等中创建图标等。如果您需要调整它们的大小,有一个名为ImageMagick的命令行实用程序,我发现它比在图像编辑器中设置大小更容易调整图像大小。您将用于调整大小的命令称为mogrify
。
Option two is to get your hands on an app called Asset Catalog Generator. You just dump your images in and it spits out the correct file sizes and naming conventions. It's probably the best $4.99 I've spent in a long time.
选项二是使用名为Asset Catalog Generator的应用程序。您只需将图像转储进去,它就会输出正确的文件大小和命名约定。这可能是我在很长一段时间内花费的最好的 4.99 美元。
UpdateIt appears someone has written a script to create the icons, too. I haven't used it myself, so you might want to poke around and look for others.
更新似乎有人也编写了一个脚本来创建图标。我自己没用过,所以你可能想四处看看,寻找其他人。
回答by Wizkid
Create your app icon (once) at a decent resolution say 1024x1024. Drop the file into MakeAppIcon(a free service) and out pops all your icons in a zip file properly sized, enhanced as necessary, and rendered. Just drop them into images.xcassets and you're done. This avoids having to tweak any icons that may be off by a pixel or two and avoids those annoying Xcode warning messages.This vendor also offer a service for bulk uploading your iTunes screenshots, but I haven't tried that yet. Luv it!
以合适的分辨率创建您的应用程序图标(一次),例如 1024x1024。将文件放入MakeAppIcon(一项免费服务)中,然后弹出一个大小合适、根据需要增强并呈现的 zip 文件中的所有图标。只需将它们放入 images.xcassets 中即可。这避免了必须调整可能偏离一两个像素的任何图标,并避免那些烦人的 Xcode 警告消息。该供应商还提供批量上传 iTunes 屏幕截图的服务,但我还没有尝试过。很喜欢!
回答by Jake3231
I would suggest you try SquareIcon, which I believe makes creating Xcode app icon sets very easy. Just to let you know, this is my own app.
我建议您尝试SquareIcon,我相信它使创建 Xcode 应用程序图标集变得非常容易。只是为了让您知道,这是我自己的应用程序。
The app allows you to drop in a generic image file (like a JPG
or PNG
) and convert it to a .appiconset
file which you can put into your project's asset catalog. This takes care of all the naming and resizing that you might have to do manually.
该应用程序允许您放入通用图像文件(如 aJPG
或PNG
)并将其转换为.appiconset
可以放入项目资产目录的文件。这会处理您可能必须手动执行的所有命名和调整大小。
回答by Santosh Botre
You can use the vector-based images from a PDF. Session 411 from WWDC “What's New in Interface Builder” discussed—albeit very briefly—Xcode's support for creating your PNG files at build time from a vectorised PDF.
您可以使用 PDF 中的基于矢量的图像。来自 WWDC“Interface Builder 中的新功能”的 411 会议讨论了(尽管非常简短)Xcode 对在构建时从矢量化 PDF 创建 PNG 文件的支持。
There is good article on this, you can refer that as well. http://martiancraft.com/blog/2014/09/vector-images-xcode6/
这方面有好文章,你也可以参考。http://martiancraft.com/blog/2014/09/vector-images-xcode6/
(Note that this does NOT cover PDFs for icons, just for images)
(请注意,这不包括用于图标的 PDF,仅用于图像)
回答by FreeNickname
UPDATE 2: I might've misunderstood you. When I wrote this answer, I thought that by 'inefficiency' you meant memory consumption and the resulting app size. If you meant, that making an icon for all the sizes is a lot of work, and you're looking for a better way to do it, consider looking at Adrian B's answer instead.
更新 2:我可能误解了你。当我写这个答案时,我认为“低效率”是指内存消耗和由此产生的应用程序大小。如果您的意思是,为所有尺寸制作图标需要大量工作,并且您正在寻找更好的方法,请考虑查看 Adrian B 的答案。
First of all, no, there is no more efficient way of doing it (unfortunately). Xcode supports vector images, but they are only supported on OS X, AFAIK. On iOS it just generates all necessary images at compile time.
首先,不,没有更有效的方法(不幸的是)。Xcode 支持矢量图像,但它们仅在 OS X、AFAIK 上受支持。在 iOS 上,它只在编译时生成所有必要的图像。
Second, the app icon is small. You won't save a lot of space by optimizing app icon size. If you need to decrease the app size, try finding something that really takes much space. The icon doesn't.
其次,应用程序图标小。优化应用程序图标大小不会节省大量空间。如果您需要减小应用程序的大小,请尝试寻找真正占用大量空间的内容。图标没有。
UPDATE:Luckily, Apple realizes, that forcing everybody to download resources that they don't need is no good. So they introduced App Thinningalong with iOS 9. I haven't looked into it thoroughly yet, but the general idea is that you upload a binary containing all the resources as usual, but when your users download the app from the AppStore, they get a version containing only resources that they need.
更新:幸运的是,Apple 意识到,强迫每个人下载他们不需要的资源是没有好处的。所以他们在 iOS 9 中引入了App Thinning。我还没有深入研究它,但总体思路是你像往常一样上传一个包含所有资源的二进制文件,但是当你的用户从 AppStore 下载应用程序时,他们得到一个只包含他们需要的资源的版本。