How to reset the context to the original rectangle after clipping it for drawing?
<p>I try to draw a sequence of pattern images (different repeated patterns in one view).</p>

<p>So what I did is this, in a loop:</p>

<pre><code>CGContextRef context = UIGraphicsGetCurrentContext();

// clip to the drawing rectangle to draw the pattern for this portion of the view
CGContextClipToRect(context, drawingRect);

// the first call here works fine... but for the next nothing will be drawn
CGContextDrawTiledImage(context, CGRectMake(0, 0, 2, 31), [img CGImage]);
</code></pre>

<p>I think that after I've clipped the context to draw the pattern in the specific rectangle, I cut out a snippet from the big canvas and the next time, my canvas is gone. can't cut out another snippet. So I must reset that clipping somehow in order to be able to draw another pattern again somewhere else?</p>

<p>Edit: In the documentation I found this:</p>

<blockquote>
  <p>CGContextClip: "... Therefore, to
  re-enlarge the paintable area by
  restoring the clipping path to a prior
  state, you must save the graphics
  state before you clip and restore the
  graphics state after you’ve completed
  any clipped drawing. ..."</p>
</blockquote>

<p>Well then, how to store the graphics state before clipping and how to restore it?</p>
