views:

74

answers:

2

While developing a rounded rectangle widget I encountered the following problem: path built with arcs looks ugly when stroked.

picture

How to make the stroked arcs look nicer?

+1  A: 

One trick with quartz drawing is to offset things by half a pixel. Try insetting your rect before drawing:

rect = CGRectInset( rect , -0.5 , -0.5 );

Doing +0.5 instead of -0.5 would make the rectangle smaller.

drawnonward
I found this at the very same moment. In my case it is positive offset that helped.
ciukes
A: 

Here's outline of the solution valid for any given line width:

- (void)drawRect:(CGRect)rect {
    CGFloat lineWidth=1.5;
    rect = CGRectInset(rect, lineWidth , lineWidth);
    ...
    CGContextSetLineWidth(context, lineWidth);
        ...
}
ciukes