[英]How do I get the desktop icon used in Finder?
In Objective-c/Cocoa, how do I get the icon that Finder uses for the desktop (it looks like the black/pink nebula desktop image with a menu bar and dock). 在Objective-c / Cocoa中,如何获取Finder用于桌面的图标(它看起来像带有菜单栏和停靠点的黑色/粉红色星云桌面图像)。
I tried this: 我尝试了这个:
NSImage *icon = [[NSWorkspace sharedWorkspace]
iconForFileType: NSFileTypeForHFSTypeCode(kDesktopIcon)];
But all I get is a blue folder with a ghosted desktop-looking box on it. 但是我所得到的只是一个蓝色的文件夹,上面有一个看起来像桌面的盒子。 Is there another constant that provides this icon, or another method altogether for getting the icon?
是否有提供此图标的另一个常量,或提供该图标的另一种方法?
The icon you're looking for is located at: /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ToolbarDesktopFolderIcon.icns 您要查找的图标位于:/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ToolbarDesktopFolderIcon.icns
I wasn't able to find a constant for it, but you could load the image in with imageWithContentsOfFile:. 我无法为其找到常量,但是您可以使用imageWithContentsOfFile:加载图像。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.