Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drawing with Core Graphics looks chunky on Retina display

I have a UIView that draws a circle from inside drawRect:rect. After reading the Apple dev info on the Retina display, it seemed like using Core Graphics meant that the drawings would automatically take advantage of the higher res. This simple circle, however, looks pretty chunky as compared to a similar circle in a badge icon. Obviously I'm comparing it to something that has gloss and shadow but I think it's pretty obvious that mine is not being drawn as well. I tried taking screenshots of apple's icon badge and my circle and they look about the same on my mac - the difference is obvious when looking at each on the phone, though. Is there something simple I'm missing here?

This is the drawing code that I'm using in drawRect:rect

UIBezierPath* aPath = [UIBezierPath bezierPathWithOvalInRect:
                       CGRectMake(0, 0, 22, 22)];

[[UIColor whiteColor] setStroke];
[[UIColor redColor] setFill];

CGContextRef aRef = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(aRef, 10, 10);
aPath.lineWidth = 3;
[aPath fill];
[aPath stroke];

Thanks for any help, Rob

like image 236
r duarte Avatar asked Dec 29 '22 00:12

r duarte


1 Answers

Oops, it needed antialiasing first:

CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetShouldAntialias(context, YES);

I added this before drawing, then set it to NO and drew another circle immediately afterward. The two circles, side by side, show that this was the problem.

like image 88
r duarte Avatar answered Dec 31 '22 12:12

r duarte