title: Providing layer content via quartz2D drawings in xcode 6
body: <p>Hi according to <a href="https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CoreAnimation_guide/SettingUpLayerObjects/SettingUpLayerObjects.html#//apple_ref/doc/uid/TP40004514-CH13-SW12" rel="nofollow">the core animation programming guide</a> you can provide a layers content by calling a custom layer class and manually writing a display method where the you provide the content. I want to use a quartz2D drawing for the content (written in a separate custom class that uses quartz) but I do not know how.</p>
  
  <p>I am trying to use the display method here</p>
  
  
  
  <pre><code>-(void) displayLayer: (CALayer *)layer inContext:(CGColorSpaceRef)ctc  inContext:(CGContextRef)ctx {}
  </code></pre>
  
  <p>the method for the quartz2D drawing </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>- (void)drawRect:(CGRect)rect {
          
          CGContextRef context = UIGraphicsGetCurrentContext();
          
          CGContextSetLineWidth(context, 2.0);
          
          CGContextSetStrokeColorWithColor(context, [UIColor blueColor].CGColor);
          
          CGRect rectangle = CGRectMake(60,170,200,80);
          
          CGContextAddRect(context, rectangle);
          
          CGContextStrokePath(context);
  }</code></pre>
  </div>
  </div>
  </p>