title: In iOS Development, using Core Graphics and/or Quartz 2D, how can I draw a circle filled with a gradient in such a manner that it looks like a sphere?
body: <p>So far I have looked at using CGContextDrawLinearGradient() and CGContextDrawRadialGradient(), however, with the former I can't figure out how to make the gradient look like a sphere, and with the latter, I can't figure out how to make the gradient into the shape of a sphere, because every time I try, it turns out in the shape of the full cylinder instead of only a sphere.</p>
  
  <p>The code I am using to current draw a 2D circle is shown below. I would like to use a gradient or any other method possible using only Core Graphics and/or Quartz 2D to fill the circle in a manner that makes it look like a sphere.</p>
  
  <p>Current code for drawing a circle:</p>
  
  <pre><code>CGContextRef ctx = UIGraphicsGetCurrentContext();
  float x = 20.0;
  float y = 20.0;
  float radius = 12.5;
  CGContextFillEllipseInRect(ctx, CGRectMake(x, y, radius, radius);
  </code></pre>
  
  <p>P.S. - The above code works just as its supposed to, so in case there are any errors, they're just from my errors while typing the question, not while typing code into the actual file.</p>