CGContextSaveGState
CGContextSaveGState is a function in Core Graphics that pushes a copy of the current graphics state onto the graphics state stack for a given graphics context. The graphics state is a collection of settings that affect drawing operations, and saving it allows a program to temporarily modify these settings and later restore them to their previous values. The save operation is per-context, so each CGContext has its own stack.
A graphics state typically includes transformation information (the current transformation matrix), the clipping path, alpha and
Common usage patterns involve saving the state before applying a local change, performing drawing with the
In Swift, the equivalent calls are context.saveGState() and context.restoreGState(), while in Objective-C they are CGContextSaveGState(context) and