将图标(mac& pc)添加到包含Cocoa的文件 [英] Add an icon (mac & pc) to a file with Cocoa

查看:102
本文介绍了将图标(mac& pc)添加到包含Cocoa的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的iPhone应用程式中的一个档案中加入一个图示(icns& ico),我不太确定从哪里开始寻找!因此,当在Finder或Windows资源管理器中查看此文件时,将会有一个自定义图标。

I want to add an icon (icns & ico) to a file within my iPhone app and I'm not quite sure where to start looking! So when this file is viewed in Finder or Windows Explorer it will have a custom icon.

任何人都能指向正确的方向?

Can anyone point me in the right direction?

推荐答案

我没有Windows资源管理器的答案。对于MacOS,文件的自定义图标存储在文件的资源分支中,如 kIconFamilyType ,ID为 kCustomIconResource 。文件夹的自定义图标存储在文件夹中名为 Icon\r (\r表示mac换行符)的文件中。对于卷,自定义图标位于卷的根目录中的 .VolumeIcon.icns 文件中。在每种情况下,您必须为该项设置 kHasCustomIcon Finder标记。

I do not have an answer for Windows Explorer. For MacOS, the custom icon of a file is stored in the resource fork of the file as kIconFamilyType with id kCustomIconResource. The custom icon for a folder is stored in a file named Icon\r (\r meaning mac newline) in the folder. For volumes, the custom icon is in a .VolumeIcon.icns file at the root of the volume. In each case, you must set the kHasCustomIcon Finder flag for the item.

Cocoa不允许您访问资源fork或Finder标志。使用FSSetCatalogInfo设置Finder标志。使用FSCreateResourceFork,AddResource和CloseResFile将自定义图标系列添加到文件。相同的资源分支调用用于文件夹中的自定义图标文件。

Cocoa does not give you access to the resource fork or the Finder flags. Use FSSetCatalogInfo to set the Finder flags. Use FSCreateResourceFork, AddResource and CloseResFile to add a custom icon family to a file. The same resource fork calls are used for the custom icon file in a folder.

设置图标的常用方法是从获取信息查询器窗口,或者向Finder发送一个苹果事件。你可以从可可发送苹果事件,但这是没有从iPhone的帮助。

The usual way to set an icon is to either paste it in from the Get Info Finder window, or send the Finder an apple event. You can send apple events from cocoa, but that is no help from an iPhone.

要在iPhone上创建一个有资源分支的文件,你可能需要构建一个zip文件,在解压缩时创建一个资源分叉。您必须手动构建围绕图标系列数据的资源分支包装器。资源分支结构已有详细记录。

To create a file on an iPhone that has a resource fork, you would probably have to build a zip archive that would create a resource fork when unzipped. You would have to manually build a resource fork wrapper around the icon family data. The resource fork structure is well documented.

在MacOS上有一个辅助应用程序可能会更容易。

It would probably be easier to have a helper application on MacOS.

这篇关于将图标(mac& pc)添加到包含Cocoa的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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