• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSAttributedString with embedded image
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >NSAttributedString with embedded image (From: Craig Hunter <email@hidden>)

  • Prev by Date: ObjectiveC++ strange warning at class declaration
  • Next by Date: Re: Possible to bind file contents to a view?
  • Previous by thread: NSAttributedString with embedded image
  • Next by thread: Re: NSAttributedString with embedded image
  • Index(es):
    • Date
    • Thread