vinay
vinay

Reputation: 61

CGContextRef undo drawn paintings?

How to Undo drawn paintings in CGContextRef(Iphone)?

Upvotes: 0

Views: 804

Answers (2)

visakh7
visakh7

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

Eiko
Eiko

Reputation: 25632

You can't. You need to draw the whole thing again.

Upvotes: 1

Related Questions