2013-02-27 59 views
0

我想将填充颜色添加到圆形。此代码不工作:使用Quartz设置圆形填充颜色

CGContextRef context = UIGraphicsGetCurrentContext(); 
    CGContextSetLineWidth(context, 2.0); 
    CGContextSetRGBStrokeColor(context, 0, 0, 225, 1); 
    CGContextSetRGBFillColor(context, 0, 255, 0, 1); 
    CGContextAddArc(context, pointWhereUserClickedX, pointWhereUserClickedY, 50, 0, 2*3.14159265359, YES); 
    CGContextDrawPath(context, kCGPathStroke); 

出了什么问题?

+0

它以什么方式不起作用? – 2013-02-27 17:37:21

回答

0

您没有填充填充颜色的圆圈。

- (void)drawRect:(CGRect)rect { 
    //your code and add this line: 
    CGContextFillEllipseInRect(contextRef, rect); 
    } 
+0

也不能工作:( – 2013-02-27 21:26:51

0

必须在最后一行此使用:

CGContextDrawPath(背景下,kCGPathFillStroke);

+0

不工作:((((( – 2013-02-27 18:00:26

+0

如果不工作,请检查drawRect是否使用setNeedsDisplay调用。在我的解决方案中,我有一个UIView,上面的代码在drawRect中。如果您想要更详细的答案添加更多的代码,请。 – jackdev23 2013-02-28 09:21:54