title: IOS, how to clear context graphics
body: <p>In my app I have a method that draws a pdf into a context:</p>
  
  <pre><code> CGPDFPageRef page = CGPDFDocumentGetPage(pdf, index + 1);
  
   CGAffineTransform transform = aspectFit(CGPDFPageGetBoxRect(page, kCGPDFTrimBox),
                                                            CGContextGetClipBoundingBox(ctx));
  
   CGContextConcatCTM(ctx, transform);
  
   CGContextDrawPDFPage(ctx, page);
  </code></pre>
  
  <p>Now in drawLayer, that is called when zooming, I do the necessary transformations and call again <code>CGContextDrawPDFPage(ctx, page);</code></p>
  
  <p>What happens is that a zoomed pdf is drawn on top of the first pdf, the problem is that in a particular page with only text, the back and blurred pdf is shown. That is strange, I thought that pdf page had white background and if this happens it's because the zoomed pdf on top has transparent background.</p>
  
  <p>Now, to solve this how can I clear the context right before the CGContextDrawPDFPage(ctx, page) of drawLayer method? I tried:</p>
  
  <pre><code>//self.view.transform = CGAffineTransformIdentity;
  
  //CGAffineTransform transform = CGAffineTransformIdentity;
  //CGContextConcatCTM(ctx, transform);
  
  //CGContextClearRect(ctx, layer.bounds);
  </code></pre>
  
  <p>Nothing works...thanks in advance</p>