Re: CGContext - Drawing Circle
Re: CGContext - Drawing Circle
- Subject: Re: CGContext - Drawing Circle
- From: Dave <email@hidden>
- Date: Thu, 04 Jul 2013 13:33:22 +0100
Hi,
Thanks for your help. The top/bottom/left/right sides of the "circle" as flattened, I've also tried the elipse function "CGContextStrokeEllipseInRect", which is the same.
I'm using a Rect of size 30,30 as theDrawRect input parameter.
Cheers
Dave
On 4 Jul 2013, at 13:01, Ronald Hofmann <email@hidden> wrote:
> Could you please post a screenshot of this crappy circle?
>
> Regards
> Ronald
> ---
>
>> Am 04.07.2013 um 13:44 schrieb Dave <email@hidden>:
>>
>> Hi,
>>
>> I have a custom class, subclassed from UIControl that draws a circle with an X in it (like a circular check box control). This works ok, but the circle looks scrappy when displayed on the iPad. The method that does the work is appended to this mail and is called from the drawRect method of the class.
>>
>> Is there something I am doing wrong? It really doesn't look like a nice circle!
>>
>> Thanks in advance,
>> Dave
>>
>> - (void) drawCheckBoxStyleCircle:(CGRect) theDrawRect
>> {
>> CGContextRef myGraphicsContext;
>> CGFloat myStrokeColor[4] = {0,0,0,1};
>> CGFloat myFillColor[4] = {255,255,255,1};
>> CGColorSpaceRef myColorspaceRef;
>> CGFloat myCenterXPosition;
>> CGFloat myCenterYPosition;
>> CGFloat myRadius;
>> CGRect myInnerRect;
>>
>>
>> myGraphicsContext = UIGraphicsGetCurrentContext();
>>
>> CGContextSetStrokeColor(myGraphicsContext,myStrokeColor);
>> CGContextSetFillColor(myGraphicsContext,myFillColor);
>>
>> myColorspaceRef = CGColorSpaceCreateDeviceRGB();
>>
>> myCenterXPosition = theDrawRect.origin.x + (theDrawRect.size.width / 2);
>> myCenterYPosition = theDrawRect.origin.y + (theDrawRect.size.height / 2);
>> myRadius = theDrawRect.size.width / 2;
>>
>> CGContextSetLineWidth(myGraphicsContext,2);
>> CGContextAddArc(myGraphicsContext,myCenterXPosition,myCenterYPosition,myRadius,0,2 * M_PI,1);
>> CGContextStrokePath(myGraphicsContext);
>>
>> if (self.pCheckBoxSelectedFlag == YES)
>> {
>> myInnerRect = CGRectMake(CGRectGetMinX(theDrawRect) + 6,CGRectGetMinY(theDrawRect) + 6,CGRectGetWidth(theDrawRect) - 12,CGRectGetHeight(theDrawRect) - 12);
>> CGContextSetLineWidth(myGraphicsContext,3);
>>
>> CGContextBeginPath(myGraphicsContext);
>> CGContextMoveToPoint(myGraphicsContext,CGRectGetMinX(myInnerRect),CGRectGetMinY(myInnerRect));
>> CGContextAddLineToPoint(myGraphicsContext,CGRectGetMaxX(myInnerRect),CGRectGetMaxY(myInnerRect));
>> CGContextStrokePath(myGraphicsContext);
>>
>> CGContextMoveToPoint(myGraphicsContext,CGRectGetMinX(myInnerRect),CGRectGetMaxY(myInnerRect));
>> CGContextAddLineToPoint(myGraphicsContext,CGRectGetMaxX(myInnerRect),CGRectGetMinY(myInnerRect));
>> CGContextStrokePath(myGraphicsContext);
>> }
>> }
>>
>> _______________________________________________
>>
>> Cocoa-dev mailing list (email@hidden)
>>
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden