If I save and restore the CurrentGraphicsContext, will that revert my drawing back to original state?

StackOverflow https://stackoverflow.com/questions/21972937

  •  15-10-2022
  •  | 
  •  

Frage

I have an iPad app where I draw a grid of dates along the x axis and times down the y axis. I then draw colored bars (using CGContext methods) in specific sections of this grid (see image).

If I change the data that is used to draw the bars, the old bars are still visible and the new bars are not. If I use -CGContextSaveGState and -CGContextSaveGState, will that "clear" the old data so the grid is as it was originally without any bars?

enter image description here

War es hilfreich?

Lösung 2

No. Just the graphical context is restored (graphical engine state machine), not what the engine has produced.

Andere Tipps

I think Vincent answered your question, but what you need to do now is to redraw all the bars from scratch on the background grid. Call setNeedsDisplay for the view that draws the background and the bars when the bar parameters change. Your drawRect should then recreate the grid and bars.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top