My drawInContext method looks something like this:
- (void)drawInContext:(CGContextRef)context {
CGRect circleRect = CGRectInset(self.bounds, 1, 1);
UIColor * __autoreleasing borderColor = [UIColor whiteColor];
UIColor * __autoreleasing backgroundColor = [UIColor colorWithWhite:0 alpha: 0.75];
CGContextSetFillColorWithColor(context, backgroundColor.CGColor );
CGContextSetStrokeColorWithColor(context, borderColor.CGColor );
CGContextSetLineWidth(context, 2.0f);
CGContextFillEllipseInRect(context, circleRect);
CGContextStrokeEllipseInRect(context, circleRect);
CGFloat radius = MIN(CGRectGetMidX(circleRect), CGRectGetMidY(circleRect));
CGPoint center = CGPointMake(radius, CGRectGetMidY(circleRect));
CGFloat startAngle = -M_PI / 2;
CGFloat endAngle = self.progress * 2 * M_PI + startAngle;
CGContextSetFillColorWithColor(context, borderColor.CGColor );
CGContextMoveToPoint(context, center.x, center.y);
CGContextAddArc(context, center.x, center.y, radius, startAngle, endAngle, 0);
CGContextClosePath(context);
CGContextFillPath(context);
[super drawInContext:context];
}
But on my iPhone Retina display it looks very pixeled as the screenshot demonstrates. How cat I repair this?
Okay, I found the solution. To draw a beautifully scaled image one needs to do the following:
pie_layer.contentsScale = [UIScreen mainScreen].scale;
See also this post: CGContext text drawing doesn't scale up on iPhone 4