title: Smoothing a rounded stroke in Core Graphics
body: <p>I am creating my own UITableViewCells with a gradient background.  I have all the logic and drawing worked out, but one thing I want to fix is the "chunkiness" around the corners of my custom cell:</p>
  
  <p><a href="http://grab.by/27SM" rel="nofollow noreferrer">alt text http://grab.by/27SM</a></p>
  
  <p>If you zoom in on the corners, you can see what I am talking about.  Here is the code I a using to generate the cell:</p>
  
  <pre><code>CGContextRef c = UIGraphicsGetCurrentContext();
  CGColorSpaceRef myColorspace = CGColorSpaceCreateDeviceRGB();
  CGGradientRef myGradient = nil;
  CGFloat components[8] = TABLE_CELL_BACKGROUND;
  CGContextSetStrokeColorWithColor(c, [[UAColor colorWithWhite:0.7 alpha:1] CGColor]);
  CGContextSetLineWidth(c, 2);
  CGContextSetAllowsAntialiasing(c, YES);
  CGContextSetShouldAntialias(c, YES);
  CGFloat minx = CGRectGetMinX(rect) , midx = CGRectGetMidX(rect), maxx = CGRectGetMaxX(rect) ;
  CGFloat miny = CGRectGetMinY(rect) , maxy = CGRectGetMaxY(rect) ;
  
  CGMutablePathRef path = CGPathCreateMutable();
  CGPathMoveToPoint(path, NULL, minx, miny);
  CGPathAddArcToPoint(path, NULL, minx, maxy, midx, maxy, kDefaultMargin);
  CGPathAddArcToPoint(path, NULL, maxx, maxy, maxx, miny, kDefaultMargin);
  CGPathAddLineToPoint(path, NULL, maxx, miny);
  CGPathAddLineToPoint(path, NULL, minx, miny);
  CGPathCloseSubpath(path);
  
  // Fill and stroke the path
  CGContextSaveGState(c);
  CGContextAddPath(c, path);
  CGContextClip(c);
  
  CGFloat locations[2] = { 0.0, 1.0 };
  CGFloat mycomponents[8] = TABLE_CELL_BACKGROUND;
  CGColorSpaceRef myColorspace = CGColorSpaceCreateDeviceRGB();
  myGradient = CGGradientCreateWithColorComponents(myColorspace, mycomponents, locations, 2);
  CGContextDrawLinearGradient(c, myGradient, CGPointMake(minx,miny), CGPointMake(minx,maxy), 0);
  
  CGContextRestoreGState(c);  
  CGContextAddPath(c, path);
  CGContextStrokePath(c);
  </code></pre>
  
  <p>What can I do to smooth the edges while keeping a consistent edge thickness across all cells?</p>