如何在Xcode中设置Mac应用程序的图标? [英] How can I set the icon for a Mac Application in Xcode?

查看:234
本文介绍了如何在Xcode中设置Mac应用程序的图标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Interface Builder中学习了很多关于编写Objective-C代码和设计的知识,我想为我的简单程序设置图标。



JPG到所有大小字段的Icon Composer,并得到一个ICNS,但我不知道如何添加到项目。



提前感谢。 / p>

解决方案

由于Xcode 4.4 Icon Composer不再是创建图标的推荐方式,因此不再包含在Xcode的标准安装中。
由于引入了具有视网膜显示器的Mac,现在建议提供所有图形的高分辨率版本,包括应用程序图标。



为了让您的应用程序图标下的Xcode> 4.4执行以下操作:


  1. 在Finder中创建一个文件夹[IconName] .iconset

    li>
  2. 在此文件夹中将图标放置为png文件。您需要
    尺寸的图片,尺寸为16像素,32像素,64像素(仅Retina),128像素,256像素,512像素和
    1024像素(仅限Retina)


  3. 这些图标必须以图案icon_16x16.png,
    icon_32x32.png,icon_128x128.png等命名。


  4. 要支持视网膜显示器,您还必须添加双
    分辨率的图标文件,名为icon_16x16@2x.png(大小为32x32),
    icon_32x32@2x.png(大小为64x64)等等,最多为icon_512x512 @ 2x.png(大小1024x1024)。


  5. 将此[IconName] .iconset文件夹拖到Xcode >在info.plist文件中将CFBundleIconFile(图标文件为键)值设置为
    [IconName]但不包含.iconset扩展名


注释:





  • 如果您不提供每个图标文件,它通常也会工作。

  • iconset文件夹不应包含icon_64x64 .png文件。 64px图标仅适用于icon_32x32的视网膜版本



更新:
结束您的.iconset文件夹包含以下10个项目:

  icon_16x16.png 
icon_16x16@2x.png
icon_32x32.png
icon_32x32@2x.png
icon_128x128.png
icon_128x128@2x.png
icon_256x256.png
icon_256x256@2x.png
icon_512x512 .png
icon_512x512@2x.png

官方指南



https://developer.apple.com/library/mac/#documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Optimizing/Optimizing.html



< h1>其他信息:

要将iconset文件夹转换为icns文件,请在终端上运行以下命令: b
$ b

  iconutil -c icns [IconName] .iconset 

其中[IconName]应该替换为iconset文件夹的前缀。您现在有一个名为[IconName] .icns的文件。在XCode 4.4中,在目标摘要中,右键单击该图标的问号,然后选择icns文件。然后,您应该会看到问号已替换为图标。


I have been learning a lot about writing Objective-C code and designing in Interface Builder and I wanted to set icons for my simple programs.

I added the same JPG to all the size fields in Icon Composer and got an ICNS, but I couldn't figure out how to add it to the project.

Thank you in advance.

解决方案

Since Xcode 4.4 Icon Composer is no longer the recommended way to create icons and is no longer included in the standard install of Xcode. Due to the introduction of Macs with retina display, it is now recommended to provide high resolution versions of all graphics including app icons.

To give your app an icon under Xcode > 4.4 do the following:

  1. Create a folder [IconName].iconset in Finder

  2. In this folder place your icon as png files. You'll need the icon in sizes of 16px, 32px, 64px (retina only), 128px, 256px, 512px and 1024px (retina only)

  3. These icons must be named with the pattern icon_16x16.png, icon_32x32.png, icon_128x128.png and so on

  4. To support retina displays you must also add icon files with double resolution, named icon_16x16@2x.png (with size 32x32), icon_32x32@2x.png (size 64x64) and so on up to icon_512x512@2x.png (size 1024x1024).

  5. drag this [IconName].iconset folder to Xcode (copy if necessary)

  6. in the info.plist file set the "CFBundleIconFile" (Icon File as Key) value to [IconName] but without the .iconset extension

Annotations:

  • it is (currently) not required to provide the @2x icons
  • it will (usually) also work if you don't provide every icon file
  • the iconset folder should not contain a icon_64x64.png file. the 64px icon is only for the retina version of the icon_32x32

Update: In the end your .iconset folder has the following 10 items:

icon_16x16.png
icon_16x16@2x.png
icon_32x32.png
icon_32x32@2x.png
icon_128x128.png
icon_128x128@2x.png
icon_256x256.png
icon_256x256@2x.png
icon_512x512.png
icon_512x512@2x.png

Official guide:

https://developer.apple.com/library/mac/#documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Optimizing/Optimizing.html

Additional information:

To convert the iconset folder to an icns file, run the following command on the terminal:

iconutil -c icns [IconName].iconset

where [IconName] should be replaced with the prefix of the iconset folder. You now have a file called [IconName].icns. In XCode 4.4, in the Target Summary, right click the question mark for the icon, then select the icns file. You should then see the question mark get replaced with the icon.

这篇关于如何在Xcode中设置Mac应用程序的图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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