Roman V
Roman V

Reputation: 21

iOS Sequential Drawing Without Erasing Previously Drawn

I am simply trying to draw a bunch of lines to a view, depending on user interaction. For example, the user presses a button, and one line is drawn. The user presses another button, and another line is drawn, but the first one is still there, and so on. It seems like a trivial task, but from what I've been reading, non-destructive drawing is not very straightforward. Can anyone guide me in the right direction, ideally towards some sample code? Any kind of guidance is really appreciated though, of course. Literally just need to keep drawing various straight lines onto a view. Thanks in advance for any help!

Upvotes: 0

Views: 807

Answers (2)

Jonathan Grynspan
Jonathan Grynspan

Reputation: 43472

If you don't need undo capability, try drawing to a CGBitmapContext, then creating an image from it and rendering that to the screen as needed. This is called "back buffering" (or "double buffering" or just "buffered drawing") and is very common.

Upvotes: 1

Daniel
Daniel

Reputation: 22395

If you want to use Quartz Core, i believe you will have to re draw the whole thing every time...So someone adds a line, you draw the line, they add another line, you add both lines and so on...but you might be able to draw on layers and keep adding them on top of each other..

Upvotes: 1

Related Questions