Inside my application I’m programmatically constructing a NSImage object that I set as the applications dock Icon. I want to add some text to the icon and have been attempting to use NSString drawAtPoint: withAttributes but it doesn’t seem to be working. I’ve confirmed using log messages that the string is getting constructed properly.
I can’t seem to figure out what I’m missing, doing wrong. Any help would be greatly appreciated.
Here is the function I’ve written to draw to the NSImage
-(void) drawStringToImage:(NSString*) str{
[theIcon lockFocus];
NSLog([@"Drawing String: " stringByAppendingString:str]);
// [NSDictionary dictionaryWithObjectsAndKeys:font, NSFontAttributeName, nil];
[str drawAtPoint:NSMakePoint(5,500) withAttributes:nil];
[theIcon unlockFocus];
}
Using modified code from How to convert Text to Image in Cocoa Objective-C I was able to render text on top of a existing
NSImage