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
2009-10-18 19:31:37
Can I do that for just that UIView instance? If so, how?
Adam
2009-10-18 20:09:38
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
2009-10-18 21:36:00
That is true, I use the drawRect function to draw my shapes. How do I make use of that to clear and redraw?
Adam
2009-10-18 23:41:10
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
2009-10-19 02:35:15
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
2009-10-19 00:59:54