NSGraphicsContext class is the programmatic interface to objects that represent graphics contexts. A context can be thought of as a destination to which drawing and graphics state operations are sent for execution. Each graphics context contains its own graphics environment and state.
- macOS 10.10+
NSGraphicsContext class is an abstract superclass for destination-specific graphics contexts. You obtain instances of concrete subclasses with the class methods
At any time there is the notion of the current context. The current context for the current thread may be set using
Graphics contexts are maintained on a stack. You push a graphics context onto the stack by sending it a
saveGraphicsState() message, and pop it off the stack by sending it a
restoreGraphicsState() message. By sending
restoreGraphicsState() to an
NSGraphicsContext object you remove it from the stack, and the next graphics context on the stack becomes the current graphics context.