Compositing an NSImage
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