Is it possible to get an NSGC CGContext with -drawRect:
and use it to later execute more drawings? In a simple test such as this:
CGContextRef context = NULL; - (void)drawRect:(NSRect)r { if (!context) context = [[NSGraphicsContext currentContext] graphicsPort]; } - (void)drawSomething { CGContextSetRGBFillColor(context, 1, 0, 0, 1); CGContextFillRect(context, CGRectMake (0, 0, 100, 100)); CGContextFlush(context); }
everything works when -drawSomething
is -drawSomething
, but is it guaranteed that the context will not change?
As you can see and guess, I'm trying to get around the standard drawing method with -drawRect:
It works great for many cases, but a more procedural way of drawing will make life easier in my particular case.
winck source share