Reputation: 9545
I see a lot of sample code where they use CGContextSaveGState
and CGContextRestoreGState
. Why would I need to save the state of the context?
Upvotes: 19
Views: 11419
Reputation: 96333
In order to restore it later.
Some of the things you can change about a context are difficult (e.g., CTM) or impossible (e.g., clipping path) to change back. Saving the gstate lets you undo those changes by restoring the gstate.
The Quartz 2D Programming Guide tells all.
Upvotes: 21