如果您必须使用文件夹的自定义图标,如何以编程方式将文件夹图标放在 Finder 侧边栏上?
目前正在开发一个项目,虽然我可以通过添加到 com.apple.sidebarlists.plist 文件然后重新启动 Finder 来添加侧边栏项目,但我似乎不知道如何使用指定的自定义图标显示文件夹图标。
谁能给我指出一个可以让我这样做的链接或解决方案? 提前谢谢大家!
Am currently working on a project, and though I can add sidebar items by adding to the com.apple.sidebarlists.plist file then restarting Finder, I can't seem to know how to make the folder icons show up using its assigned custom icon.
Can anyone point me to a link or a solution that would make me do this? Thanks a bunch in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
没有受支持的方法可以使用纯可可来执行此操作。 请改用 LSSharedFileList API。 这是管理侧边栏列表的受支持方式,并且您可以在插入项目时提供自定义图标(作为图标服务中的 IconRef)。
There's no supported way to do this using pure Cocoa. Use the LSSharedFileList API, instead. It's the supported way to manage the sidebar lists, and you can provide a custom icon (as an IconRef from Icon Services) when you insert an item.
我不知道图标,但我使用
EBLaunchServices
包装器将项目添加到侧边栏,该包装器在此处提供开源:https://github.com/Eric-Bro/EBLaunchServices
它非常容易使用。 例如,要将已安装的 OSXFUSE 卷添加到侧边栏,您可以调用:
I don't know about the icons but I add items to the sidebar using the
EBLaunchServices
wrapper which is available open source here:https://github.com/Eric-Bro/EBLaunchServices
It is very easy to use. For instance to add a mounted OSXFUSE volume to the sidebar you call:
我太固执了,不能不做显而易见的事情。 我做了:
设置文件夹的图像图标。 从那时起,我进行了
com.apple.sidebarlists.plist
NSUserDefaults
附加操作,并通过 Apple Events 重新启动了 Finder。 这使得一切顺利。I was too stubborn to not do the obvious. I did:
to set the image icon for the folder. I from then I did
com.apple.sidebarlists.plist
NSUserDefaults
appending, and restarted Finder through Apple Events. That made it all work.