使用Quartz设置圆形填充颜色

时间:2013-02-27 17:32:38

标签: objective-c ipad quartz-graphics

我想在圆圈中添加填充颜色。这段代码不起作用:

    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);

有什么问题?

2 个答案:

答案 0 :(得分:0)

必须在最后一行使用:

CGContextDrawPath(context,kCGPathFillStroke);

答案 1 :(得分:0)

你没有用填充颜色填充圆圈。

 - (void)drawRect:(CGRect)rect { 
     //your code and add this line:
     CGContextFillEllipseInRect(contextRef, rect);
   }
相关问题