Question

I'm trying to hack a graphing library (https://github.com/KirillM/BarChart) that unfortunately does not offer a clearChart method. So instead, I'm thinking about turning everything to white pixels if that's possible.

I know that you can set a flag for the view to be reloaded with:

[self.myView setNeedsDisplay];

This is almost there but I'd ideally not want to dig into the library: Clear UIView of drawing?

Was it helpful?

Solution 2

I found removing all the subviews from within the bar chart module did the trick: Remove all subviews?

  [[plotView subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];

OTHER TIPS

A view is "cleared" each time it's drawn -- the view is essentially erased before -drawRect: is called, and the -drawRect: method draws whatever the view represents. If you want the chart to draw something other than what's there, you'll probably need to change the data that you give it.

It'd help if you'd say what library you're using, but one would expect some sort of method to set the data that the chart draws. Try calling that method with the null version of whatever the chart expects -- maybe it's an empty array, nil, or something along those lines.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top