Search code examples
objective-cios4

Problem with drawing circle in Objective-C


I am trying to draw a circle using the following code.

 -(void)drawRect
{
  CGContextRef contextRef = UIGraphicsGetCurrentContext();
  CGContextSetRGBFillColor(contextRef,1,0,0,1);
  CGContextFillEllipseInRect(contextRef, self.frame);

}

I am getting my circle as expected, but at the edges of the circle truncated/interrupted. How can I solve this problem?


Solution

  • Try using self.bounds instead of self.frame. What class are you subclassing? Maybe you have to use self.view.bounds or self.view.frame ?