设置非app mac os x包的图标 [英] Set icon of non app mac os x bundle

查看:250
本文介绍了设置非app mac os x包的图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何为不是应用的捆绑设置图标?我尝试使用CFBundleIconFile,但它不起作用(但如果我只是将包扩展名更改为 .app ,则图标将更改为所需的图标)。是否有其他密钥,或唯一的方法是为目录设置图标?如果是这样,是否已经有一些脚本从命令行(Xcode运行脚本)执行此操作?

How to set icon for bundle which is not an app? I tried using CFBundleIconFile, but it doesn't work (though if I just change bundle extension to .app, icon is changed to desired one). Is there another key, or the only way is to set icon for directory? If so, is there already some script to do this from command line (Xcode run script)?

推荐答案

如果您需要从CLI执行此操作...它涉及更多...

If you need to do it from CLI... It's a bit more involved...

首先,您需要添加 CFBundleIconFile 捆绑包的字符串

First, you need to add a CFBundleIconFile string to your bundle's

YourThing.bundle/Contents/Info.plist




这是开发人员获得
指定捆绑包的自定义图标的位置。
此键包含bundle的Resources文件夹中
文件的名称,
包含图标。 TextEdit将其
图标保存在名为Edit.icns文件的文件中,
但是没有关于文件的
名称必须是什么的规则。

Here's where the developer gets to specify a custom icon for the bundle. This key contains the name of a file in the bundle's Resources folder that holds the icons. TextEdit keeps its icon in a file called Edit.icns file, but there's no rule about what the name of the file must be.

那就是说,你要么需要一个ICNS文件,要么按照以下实用程序(包括其源代码)<的说明进行操作通过命令行从图像文件生成ICNS ..

That said, you either need an ICNS file, or can follow these instructions from this Utility (which includes its source code) that generates ICNS's from image files via the command line..

$ ./makeicns 




用法:makeicns [k1 = v1] [k2 = v2] ...

Usage: makeicns [k1=v1] [k2=v2] ...

键和值包括:
512:512x512图标变量的输入图像名称
256:图标的256x256变体的输入图像名称
128 :图标的128x128变体的输入图像的名称
32:图标的32x32变体的输入图像的名称
16:输入图像的名称f或图标
的16x16变体:所有不具有显式名称的变体的输入图像名称
out:输出文件的名称,默认为第一个非空输入名称,
但带有icns扩展名

Keys and values include: 512: Name of input image for 512x512 variant of icon 256: Name of input image for 256x256 variant of icon 128: Name of input image for 128x128 variant of icon 32: Name of input image for 32x32 variant of icon 16: Name of input image for 16x16 variant of icon in: Name of input image for all variants not having an explicit name out: Name of output file, defaults to first nonempty input name, but with icns extension

示例:



  makeicns -512 image.png -32 image.png




创建image.icns只有512x512和32x32变体。

Creates image.icns with only a 512x512 and a 32x32 variant.



  makeicns -in myfile.jpg -32 otherfile.png -out outfile.icns




创建大小为512的outfile.icns,
256,128和16,包含来自myfile.jpg的数据
,大小32包含来自otherfile.png的数据。

Creates outfile.icns with sizes 512, 256, 128, and 16 containing data from myfile.jpg and with size 32 containing data from otherfile.png.

这篇关于设置非app mac os x包的图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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