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.

2 Answers 2

8

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.

0
0

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.

4
  • 1
    Can I do that for just that UIView instance? If so, how?
    – Adam
    Oct 18, 2009 at 20:09
  • 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
    Oct 18, 2009 at 21:36
  • That is true, I use the drawRect function to draw my shapes. How do I make use of that to clear and redraw?
    – Adam
    Oct 18, 2009 at 23:41
  • I think you would probably be better off spending some quality time with the documentation. developer.apple.com/mac/library/documentation/Cocoa/Conceptual/…
    – Azeem.Butt
    Oct 19, 2009 at 2:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.