我正在使用 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];
提示将不胜感激。