Reputation: 151046
It seems that the standard way to draw dots, lines, circles, and Bezier paths is to draw them in inside of drawRect
. We don't directly call drawRect
, but just let iOS call it and we can use [self setNeedsDisplay]
to tell iOS to try to call drawRect
when it can...
It also seems that we cannot rely on
[self setClearsContextBeforeDrawing: NO];
to not clear the background of the view before calling drawRect
. Some details are in this question: UIView: how to do non-destructive drawing?
How about directly drawing on the screen -- without putting those code in drawRect
. For example, in ViewController.m
, have some code that directly draw dots, lines, circles on the screen. Is that possible?
Upvotes: 0
Views: 385
Reputation: 483
Without having to drop into OpenGL, the closest you can do to get around the erasure is to convert the context as an image using something like CGBitmapContextCreateImage. From there, you can retain the image in memory (or write it to disk if necessary), and then when you redraw the view, you first draw this original image into the context and then overlay it with new content.
Upvotes: 1