How to get Mac system icons like in Finder?

I want the images in my outline view to be displayed on the system icons, as well as on the left side of the Finder. I want to get icons like application, documents, desktop, etc. How to do it?

+4
source share
4 answers

NSWorkspace has a method that allows you to set custom icons in folders and files:

- (BOOL)setIcon:(NSImage *)image forFile:(NSString *)fullPath options:(NSWorkspaceIconCreationOptions)options 

Sets the file or directory icon to the specified path.

+5
source

Use NSWorkspace iconForFile : method

 NSImage *icon = [[NSWorkspace sharedWorkspace] iconForFile:@"/Applications/"]; 

edit:

take a look at these files, what are you after? Your question is a little hard to understand.

 $ ls /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/Toolbar*FolderIcon.icns /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ToolbarAppsFolderIcon.icns /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ToolbarDesktopFolderIcon.icns /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ToolbarDocumentsFolderIcon.icns /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ToolbarDownloadsFolderIcon.icns /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ToolbarLibraryFolderIcon.icns /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ToolbarMovieFolderIcon.icns /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ToolbarMusicFolderIcon.icns /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ToolbarPicturesFolderIcon.icns /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ToolbarPublicFolderIcon.icns /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ToolbarSitesFolderIcon.icns /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ToolbarUtilitiesFolderIcon.icns 
+10
source

Use -[NSWorkspace iconForFileType:] and pass the constants from IconsCore.h (filtered through NSFileTypeForHFSTypeCode , of course).

+5
source

This article about Creating icns icon files should cover what you want to do. There is also an article about creating an icon so that it looks the same as the standard folder icon , which works well for consistency. Hope this helps.

Of course, this is not related to programming.

0
source

Source: https://habr.com/ru/post/1285882/


All Articles