title: iPhone : can't control the width of drawing gradients?
body: <p>I need to draw a box filled with a gradient. I'm using a UIView and overwriting the -drawRect method.</p>
  
  <p>Here is my code (simplified):</p>
  
  <pre><code>CGContextRef c = UIGraphicsGetCurrentContext();     
  CGFloat components[8] = {158.0/255.0,36.0/255.0,134.0/255.0,1.0,115.0/255.0,26.0/255.0,93.0/255.0,1.0};
  
          CGColorSpaceRef rgbColorspace = CGColorSpaceCreateDeviceRGB();
  
          CGFloat locations[2] = {0.0,1.0};
          CGGradientRef glossGradient = CGGradientCreateWithColorComponents(rgbColorspace, components, locations, 2);
  
          CGPoint topCenter = CGPointMake(10, 0);
          CGPoint bottomCenter = CGPointMake(10, 10);
          CGContextDrawLinearGradient(c, glossGradient, topCenter, bottomCenter, 0);
  </code></pre>
  
  <p>The gradient fill at present fills the entire width of the view! What can I do to control the width of the gradient-filled box I'm drawing?</p>