문제

I am drawing jigsaw using CAShapeLayer.Drawing a line that is easy part and also i did it.But now i want to draw ellipse with cutting some portion of that ellipse.Now my question is how can i cut ellipse using CGPathAddEllipseInRect?Here is my code :

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

Hint will be appreciated.

도움이 되었습니까?

해결책

Don't use CGPathAddEllipseInRect, instead you need to calculate the start and end positions and use CGPathAddArcToPoint or, more likely, CGPathAddQuadCurveToPoint.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top