Hi!
I'm trying to create a custom UIButton that should look like a UIButtonTypeRoundedRect. In my drawRect:, I'm creating a path with first one call to CGContextMoveToPoint() and then four calls to CGContextAddArc(). I then stroke the path. However, in the resulting image the four rounded corners are clearly thicker than the rest of the path.
I suspected this had something to do with anti-aliasing, so I tried switching it off with CGContextSetShouldAntiAlias(), but then it looked even worse. I've also tried experimenting with the line width, but the arcs are always thicker than the straight lines. Apple's UIButtonTypeRoundedRect looks perfectly fine, so it must be possible to solve somehow. Does anybody have a clue?
Edit: the relevant code:
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextBeginPath(context);
CGContextMoveToPoint(context, rect.origin.x + kRoundedRectButtonRadius, rect.origin.y);
CGContextAddArc(context, rect.origin.x + rect.size.width - kRoundedRectButtonRadius, rect.origin.y + kRoundedRectButtonRadius, kRoundedRectButtonRadius, 3 * M_PI_2, 0, NO);
CGContextAddArc(context, rect.origin.x + rect.size.width - kRoundedRectButtonRadius, rect.origin.y + rect.size.height - kRoundedRectButtonRadius, kRoundedRectButtonRadius, 0, M_PI_2, NO);
CGContextAddArc(context, rect.origin.x + kRoundedRectButtonRadius, rect.origin.y + rect.size.height - kRoundedRectButtonRadius, kRoundedRectButtonRadius, M_PI_2, M_PI, NO);
CGContextAddArc(context, rect.origin.x + kRoundedRectButtonRadius, rect.origin.y + kRoundedRectButtonRadius, kRoundedRectButtonRadius, M_PI, 3 * M_PI_2, NO);
CGContextClosePath(context);
CGContextSetLineWidth(context, 1.7);
CGContextStrokePath(context);