title: Set CALayer Gradient Background
body: <p>I am trying to add a gradient to a CALayer I have created. I can set the background colour of the CALayer with the following:</p>
  
  <pre><code>self.colorLayer = [CALayer layer];
  [self.colorLayer setBackgroundColor:color.CGColor]; 
  [self.colorView setWantsLayer:YES]; 
  [self.colorView setLayer:self.colorLayer];
  </code></pre>
  
  <p>I've looked around with no success (surprisingly I thought this would have been answered many times).</p>
  
  <p>I have made a gradient with: </p>
  
  <pre><code>NSGradient *gradient = 
      [[NSGradient alloc] initWithStartingColor:[NSColor orangeColor] 
          endingColor:[NSColor lightGrayColor]];
  </code></pre>
  
  <p>But can't add it to my CALayer or add an angle.  </p>