title: How can I use CGContextDrawTiledImage to tile an image?
body: <p>I want to be able to an UI object like a UIImageView and tile an image inside of it.</p>
  
  <p>I have been able to use CGContextDrawTiledImage to update the background in the main window, but not an image view. I can do this if I modify the drawRect function inside the MainView class.</p>
  
  <p>I feel I'm close, but still missing something. Can someone point me in the right direction?</p>
  
  <pre><code>- (void)drawRect:(CGRect)rect {
  
  CGImageRef image = CGImageRetain(currentImage.CGImage);
  
  CGRect imageRect;
  imageRect.origin = CGPointMake(160, 240);
  imageRect.size = CGSizeMake(320.0, 480.0);
  
  CGContextRef uiContext = UIGraphicsGetCurrentContext();
  
  CGContextClipToRect(uiContext, CGRectMake(0.0, 0.0, rect.size.width, rect.size.height));
  
  CGContextDrawTiledImage(uiContext, imageRect, image);
  </code></pre>
  
  <p>}</p>