Re: NSAttributedString with embedded image
Re: NSAttributedString with embedded image
- Subject: Re: NSAttributedString with embedded image
- From: Rakka <email@hidden>
- Date: Mon, 28 Mar 2005 18:52:54 +1000
On Mar 28, 2005, at 2:32 PM, Craig Hunter wrote:
I am trying to add a menu item to an app's dock menu with an image and text.
I have it working well with text only. My understanding is that to add both
an image and text to a dock menu item, I need to use an NSAttributedString
that contains both the image and the text. Sounds easy enough, but I have
been unable to construct an NSAttributedString with an embedded image and
text.
Anybody have a code example of constructing an NSAttributedString with an
embedded image and some text? BTW, my image is included in the app's bundle
as a resource.
thanks,
Craig
hi,
I would just create an outlet in IB (e.g theItem) connecting it to the menu item you want. Then in Xcode, declare an NSImage (e.g image) and NSString (e.g imagePath), then initWithContentsOfFile.
imagePath = [[NSBundle mainBundle] pathForResource:@"MyImage" ofType:@"tif"];
image = [[NSImage alloc] initWithContentsOfFile:imagePath];
After that, use [theItem setImage:image];
Hope that helps.
Regards,
Rakka
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden