I have the following code:
- (void)drawRect:(CGRect)rect {
CGContextRef c = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(c, [UIColor blackColor].CGColor);
CGContextFillRect(c, rect);
CGContextSetLineJoin(c, kCGLineJoinRound);
CGContextSetLineCap(c, kCGLineCapRound);
CGContextSetLineWidth(c, 50.0);
CGContextSetStrokeColorWithColor(c, [UIColor redColor].CGColor);
CGContextBeginPath(c);
CGContextMoveToPoint(c, 60, 60);
CGContextAddLineToPoint(c, 60, 250);
CGContextAddLineToPoint(c, 60, 249);
CGContextStrokePath(c);
CGContextSetStrokeColorWithColor(c, [UIColor blueColor].CGColor);
CGContextBeginPath(c);
CGContextMoveToPoint(c, 160, 60);
CGContextAddLineToPoint(c, 160, 250);
CGContextAddLineToPoint(c, 160.01, 249);
CGContextStrokePath(c);
}
This generates the following output:

Is there a good reason that the red shape’s bottom edge is not rounded? Or is it a bug in Core Graphics when the line exactly doubles back on itself?
It’s definitely a bug. If you try adding another line to the path, you can see how Core Graphics is unable to handle it.
It’s as if the masking that creates the rounded caps and joins gets inverted when it’s doubled.