View Full Version : Simple Draw an arc problem

Dec 19, 2008, 02:50 PM

Created an view based application in the Xcode and created a new View called chartView:UIView and mapped the controller using the IB .

I wanted to draw a simple arc on my ChartView . So inside my drawRect method I put the code for the arc.

CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetRGBStrokeColor(context, 1.0, 1.0, 1.0, 1.0);
CGContextSetRGBFillColor(context, 0.0, 0.0, 1.0, 1.0);
CGContextSetLineWidth(context, 2.0);
int x = 150;
int y= 100;
int r= 80;
CGContextSetRGBFillColor(context, 0, 1, 0, 1);
CGContextMoveToPoint(context, x, y);
CGContextAddArc(context,x , y, r, 0.0*M_PI/180.0, 90.0*M_PI/180.0, 0);

I see an empty screen when I start my application.

Can someone tell me if I am missing any step. Thanks For the help.

Dec 22, 2008, 02:01 AM
Start off with something basic, like filling a rect. If that works, go from there and try a basic arc. Also use positions relative to the view, using things like CGRectGetMinX instead of 0

Dec 22, 2008, 07:29 AM
I started of with the QuartzDemo example and was able to draw the arc (in fact the complete pie chart) successfully. But once I strarted to draw the arc on the project which I created I am having the problem. Nothing shows on the screen.

But when I drag and drop a text field or a label using the interface builder, I can see them on the simulator.

Thanks for the help.

Dec 22, 2008, 10:02 AM
issues fixed. had to delete an extra view on my Mainview.