Draw text on NSImage

I try my best to find good tutorials or posts on how to draw text on NSImage. I have the feeling that this is a fairly simple process, but I just can’t solve it!

I already have NSImage, and I need to eventually process NSImage at the end.

Has anyone understood how I can do this?

Thanks Tom.

+3
source share
2 answers

There may be an easier way, but personally, I would go for it using the following methods.

To put text on an image, use the NSString method:

- (void)drawInRect:(NSRect)aRect withAttributes:(NSDictionary *)attributes

Then (I assume you want this to persist on your image), use the NSImage method:

NSImage *newImage = [[NSImage alloc] initWithData:[myView dataWithPDFInsideRect:[oldImage frame];
+3
source
-1

All Articles