我试图在下面的图像中绘制两个圆圈之一。使用Quartz绘制两个圆圈CGContextFillEllipseInRect
我已成功地画出一个圆(外一种)很好,但我不知道如何添加在最上层的第二圆,以及如何居中。
- (void)drawRect:(CGRect)rect {
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 4.0);
CGContextSetStrokeColorWithColor(context,
[UIColor whiteColor].CGColor);
//
UIColor *theFillColor = UIColorFromRGB(0x6c83a6);
CGContextSetFillColor(context, CGColorGetComponents(theFillColor.CGColor));
CGRect rectangle = CGRectMake(5.0,5.0,rect.size.width-10.0,rect.size.height-10.0);
CGContextAddEllipseInRect(context, rectangle);
CGContextStrokePath(context);
CGContextFillEllipseInRect(context, rectangle);
UIGraphicsEndImageContext();
//
// INSIDE ?
//
}
嘿SCH,谢谢你的回答,你应该在上面的答案更改 “CGContextDrawPath(背景下,kCGPathFill);”在这两种情况下,但其他则表明它工作正常。 – chewy 2012-03-13 12:54:24
是的,我忘了。如果你想填充和描边,你也可以使用'kCGPathFillStroke'。 – sch 2012-03-13 12:58:20