2

初心者Q。

UIViewをサブクラス化して、円をレンダリングしたいと思います。

それはiPhoneでどのように行われますか?

4

1 に答える 1

6

drawRect:メソッドで行う:

   - (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();
   }
于 2010-01-17T23:48:58.810 に答える