title: Why is my CGGradient not working with a preset UIColor?
body: <p>I have this working code: </p>
  
  <pre><code>    NSMutableArray *shadowColors = [NSMutableArray arrayWithCapacity:2];
      color = [UIColor colorWithRed:0 green:0 blue:0 alpha:1]; // Declaration using components
      [shadowColors addObject:(id)[color CGColor]];
      color = [UIColor colorWithRed:1 green:1 blue:1 alpha:0.0]; // Declaration using components
      [shadowColors addObject:(id)[color CGColor]];
  
      CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB();
      CGGradientRef gradient = CGGradientCreateWithColors(space, (CFArrayRef)shadowColors, NULL);
      CGColorSpaceRelease(space);
  
      CGFloat sw = 10.0; // shadow width
  
      CGPoint top1 = CGPointMake(x, y+width/2.0);
      CGPoint top2 = CGPointMake(x + sw, y+width/2.0);
  
      CGPoint side1 = CGPointMake(x+width/2.0, y);
      CGPoint side2 = CGPointMake(x+width/2.0, y+sw);
  
      CGContextDrawLinearGradient(c, gradient, top1, top2, 0);
      CGContextDrawLinearGradient(c, gradient, side1, side2, 0);
      CGGradientRelease(gradient);
  </code></pre>
  
  <p>The color declarations are the part I'm interested in, lines 2 and 4. When I declare them as shown, they work just fine, but if I replace those two lines with the equivalent (I thought, at least) <code>[UIColor blackColor]</code> and <code>[UIColor clearColor]</code> then my gradients disappear. The colors I use don't make any difference, I can use <code>greenColor</code> and <code>redColor</code> and they still don't work.</p>
  
  <p>Am I missing something or is this a bug in Apple's frameworks?</p>
  
  <hr>
  
  <p>The code that <em>doesn't</em> work. And this is just the first section, everything else is the same.</p>
  
  <pre><code>    NSMutableArray *shadowColors = [NSMutableArray arrayWithCapacity:2];
      color = [UIColor blackColor];
      [shadowColors addObject:(id)[color CGColor]];
      color = [UIColor clearColor];
      [shadowColors addObject:(id)[color CGColor]];
  </code></pre>