title: Best way to accomplish this drawing with Quartz 2D / Core Graphics?
body: <p>As the background for one of the views in my app, I'd like to draw a fairly simple rectangular border just inside its frame. This would essentially be a rectangular gradient: a black line around the frame, fading to white about 10-20 pixels in. Unfortunately, as far as I can tell, Core Graphics doesn't provide rectangular gradients (either with <code>CGGradient</code> or <code>CGShading</code>). So I'm wondering what the best approach would be.</p>
  
  <p>Two that occur to me:</p>
  
  <ol>
  <li>Draw a series of concentric rectangles, each subsequent one lighter in color, and inset by 1px on each side. I can't think of a simpler approach, but I have to do all of the gradient calculations myself, and it might be a lot of graphics operations.</li>
  <li>Use <code>CGGradient</code> in linear mode, once for each side. But for this to work, I think I'd need to set up a trapezoidal clipping area for each side first, so that the gradients would be mitered at the corners.</li>
  </ol>
  
  <p>Seems like there <em>should</em> be a way to use path stroking to do this, but it doesn't seem like there's a way to define a pattern that's oriented differently on each side.</p>