Reputation: 61
How to Undo drawn paintings in CGContextRef(Iphone)?
Upvotes: 0
Views: 804
Reputation: 26390
CGContexts aren't inherently "undoable." You can't unfill a rectangle or restore a portion you've drawn over. The data just isn't there. In my experience, the best bet is to create a "save" method that looks at the region being altered and saves the image data in that region to the undo stack before drawing operations are performed. Then, when you decide to undo, you can take the modified region and restore it from your saved data.
Taken from How to use NSUndoManager with a UIImageView or CGContext
Upvotes: 2