I have this in a custom UIView subclass init function:
self.clearsContextBeforeDrawing=YES
However, each time I call setNeedsDisplay, it draws on top of the prior view’s drawing, rather than drawing fresh.
How can I make sure a UIView’s drawing context is empty when it draws again?
If your view is opaque, you must set the
backgroundColorproperty of the view to something to make it clear the view properly.If it’s not opaque that should work and ought to clear the view with transparent black.