iphone uiview圈?

Ian*_*ink 2 iphone render uiview

新手Q.

我希望子类化一个UIView,以便它呈现一个圆圈.

怎么在iPhone上完成?

Mar*_*pic 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();
   }
Run Code Online (Sandbox Code Playgroud)