How to clear and then redraw a quartz drawing
-
22-09-2019 - |
Question
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.
Solution
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.
OTHER TIPS
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.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow