views:

60

answers:

1

Newbie Q.

I wish to subclass a UIView so that it renders a circle.

How is that done in an iPhone?

+1  A: 

In the drawRect: method do:

   - (void)drawRect:(CGRect)rect
   {
     CGContextRef ctx = UIGraphicsGetCurrentContext();
     UIGraphicsPushContext(ctx);
     CGContextSetRGBFillColor(ctx, 1.0f, 1.0f, 1.0f, 1.0f);  // white color
     CGContextFillEllipseInRect(ctx, CGRectMake(10.0f, 10.0f, 100.0f, 100.0f));  // a white filled circle with a diameter of 100 pixels, centered in (60, 60)
     UIGraphicsPopContext();
   }
Marco Mustapic
Much thanks for your generous time to help.
BahaiResearch.com