views:

395

answers:

2

I'm making a complex drawing using quartz based on passed in information. The only part I haven't been able to figure out is how do I clear the lines, rectangles, etc that I've already drawn? Basically, I want to erase the whole drawing and just draw it again from the new data.

A: 

If you want to clear something that's not tracked as part of the current state, it's probably less expensive to just release your old context and start a new one.

Azeem.Butt
Can I do that for just that UIView instance? If so, how?
Adam
If you have a UIView then you have a drawRect implementation, so it's not going to draw anything you haven't explicitly told it to.
Azeem.Butt
That is true, I use the drawRect function to draw my shapes. How do I make use of that to clear and redraw?
Adam
I think you would probably be better off spending some quality time with the documentation. http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CocoaDrawingGuide/Introduction/Introduction.html
Azeem.Butt
A: 

If you set your UIView's clearContextBeforeDrawing property to YES, then the system should take care of filling its area with its backgroundColor before calling its drawRect: method.

Sixten Otto