• 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
Compositing an NSImage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Compositing an NSImage


  • Subject: Compositing an NSImage
  • From: Jesus De Meyer <email@hidden>
  • Date: Wed, 2 Mar 2005 18:01:10 +0100

Hi,

In my app I set a menu to have an icon. This icon contains text. Now what I do is get the image, lock focus and draw an NSAttributedString, then unlock focus and set the image.

The problem is that the method that does this gets called quite a lot. And everytime it draws the a new NSAttributedString over the old one resulting in unreadable and bold text.

Is there a way I can remove the old string before drawing a new one?

This is what I currently do:

NSImage *menuIcon = [NSImage imageNamed:@"menuIconLarge"];


[menuIcon lockFocus];


NSMutableDictionary *attributes = [NSMutableDictionary dictionary];
[attributes setObject:[NSFont menuBarFontOfSize:10.0] forKey:NSFontAttributeName];


NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"Testing"] attributes:attributes];


[attrString drawAtPoint:NSMakePoint(20, 1)];


[attrString release];


[menuIcon unlockFocus];


[statusBarItem setImage:menuIcon];

Thanks in advance
 _______________________________________________
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

  • Follow-Ups:
    • Re: Compositing an NSImage
      • From: j o a r <email@hidden>
  • Prev by Date: Running printJob sheet without printing?
  • Next by Date: Java bridge
  • Previous by thread: Re: Running printJob sheet without printing?
  • Next by thread: Re: Compositing an NSImage
  • Index(es):
    • Date
    • Thread