mbpro
mbpro

Reputation: 2490

How to add other application's icon to Toolbar in Cocoa?

I have a window with some content that could be previewed, mailed,...

I decided that the best way to do this is to put appropriate application icons in toolbar, namely from Mail, Preview,...

Trick is, how to do that? Is thee any way too access other's application package and have access to its icon? Or is there any other elegant way?

Upvotes: 1

Views: 435

Answers (2)

mbpro
mbpro

Reputation: 2490

There is also one other way of doing it, especially if you are building toolbar in IB:

  • right-click application icon
  • copy it
  • open Preview
  • select New from Clipboard

You will get complete set of application icons in any size. You can export them and put them in Image Well in IB

Upvotes: 0

Anne
Anne

Reputation: 27073

Code:

// Get icon
NSImage *theIcon = [[NSWorkspace sharedWorkspace] iconForFile:@"/Applications/Mail.app"];

// Display icon (irrelevant in your case)
[theIcon setSize:NSMakeSize(128, 128)];
[theImageView setImage:theIcon];

Upvotes: 4

Related Questions