Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSImage drawInRect and TemplateImages

In have an NSImage is a template image (that is, [NSImage isTemplate] returns YES).

When I use it inside an NSImageView, it is drawn correctly as a template image.

However, if I draw it manually using drawInRect:fromRect:operation:fraction:, it is drawn as a flat black image.

How can I draw an NSImage manually, and still get the 'template' effect?

like image 560
TheNextman Avatar asked Nov 02 '22 20:11

TheNextman


1 Answers

The special drawing of template images is part of CoreUI and not public.
You can imitate the effect with Quartz though. Details and code can be found in this answer here on SO: https://stackoverflow.com/a/7138497/100848

like image 120
Thomas Zoechling Avatar answered Nov 12 '22 18:11

Thomas Zoechling