0

我正在使用 CAShapeLayer 绘制拼图。绘制一条很容易的线,我也做到了。但是现在我想通过切割椭圆的一部分来绘制椭圆。现在我的问题是如何使用 CGPathAddEllipseInRect 切割椭圆?这是我的代码 :

CAShapeLayer *shapeLayer = [CAShapeLayer layer];
    [shapeLayer setBounds:self.bounds];
    [shapeLayer setPosition:self.center];
    [shapeLayer setFillColor:[[UIColor clearColor] CGColor]];
    [shapeLayer setStrokeColor:[[UIColor blackColor] CGColor]];
    [shapeLayer setLineWidth:3.0f];

    // Setup the path
    CGMutablePathRef path = CGPathCreateMutable();
    CGPathMoveToPoint(path, NULL, 10, 10);
    CGPathAddLineToPoint(path, NULL, 75,10);
    CGPathAddEllipseInRect(path, NULL, CGRectMake(75, 10, 50, 20));
    [shapeLayer setPath:path];
    CGPathRelease(path);

    [[self layer] addSublayer:shapeLayer];

提示将不胜感激。

4

1 回答 1

1

不要使用CGPathAddEllipseInRect,而是需要计算开始和结束位置并使用CGPathAddArcToPointor,更有可能的是,CGPathAddQuadCurveToPoint

于 2013-07-17T10:51:53.773 回答