0

I want to add fill color to a circle. This code dont work:

    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetLineWidth(context, 2.0);
    CGContextSetRGBStrokeColor(context, 0, 0, 225, 1);
    CGContextSetRGBFillColor(context, 0, 255, 0, 1);
    CGContextAddArc(context, pointWhereUserClickedX, pointWhereUserClickedY, 50, 0, 2*3.14159265359, YES);
    CGContextDrawPath(context, kCGPathStroke);

What is wrong?

1
  • In what way does it not work? Feb 27, 2013 at 17:37

2 Answers 2

0

you did not fill the circle with the fill color.

 - (void)drawRect:(CGRect)rect { 
     //your code and add this line:
     CGContextFillEllipseInRect(contextRef, rect);
   }
0
0

Must use in the last line this:

CGContextDrawPath(context, kCGPathFillStroke);

1
  • If doesn't work please check that drawRect is called by using setNeedsDisplay. In my solution I have a UIView and the above code is in drawRect. If you want a more detailed answer add more code, please.
    – jackdev23
    Feb 28, 2013 at 9:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.