我試圖在下面的圖像中繪製兩個圓圈之一。使用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