View Full Version : programmatically set background image of folder
Apr 7, 2008, 02:03 PM
I am trying to make a small drag-n-drop utility with Xcode in Objective-C / Cocoa to create dmg files, I am not sure how to programmatically set the background image of a folder. Does anyone know the name of the class that handles this?
Apr 7, 2008, 02:58 PM
There is not a Cocoa interface to this. Probably the easiest way is to tell the Finder to do it via Applescript.
Apr 7, 2008, 03:05 PM
You'll have to manipulate the Folder image, which typically (I believe) is stored in a resource fork. I not 100% about Cocoa, but other frameworks (like Qt) allow you to manipulate images by applying transparency masks. You could layer the new image onto the folder image, flatten, then write back to the file.
There's probably a simpler way of doing this, but I don't know what that might be.
Dec 8, 2008, 04:02 AM
I came here looking for the answer to the same question, and eventually found the answer from the mothership itself:
(there's a handy example at the bottom of that page)