Usm*_*wan 8 objective-c cashapelayer ios uibezierpath
我正在制作一个图像编辑器,可以创建不同的形状对象,如圆形,三角形和方形,也可以更新或删除.所以我用它CAShapeLayer来创建形状对象.
现在我也想在图像上画一条线也可以更新或删除所以我使用bezierpath并CAShapeLayer创建线,它工作正常.但现在的问题是,当我想选择任何现有线时,可以选择接近线工具的任何位置,因为CAShapeLayer还设置了从起点到终点的直线的填充区域.
我的问题是如何创建没有填充区域的线CAShapeLayer.
这是我创建行的代码:
CAShapeLayer *line = [CAShapeLayer layer];
// Using bezierpath to make line
UIBezierPath *linePath=[UIBezierPath bezierPath];
// Creating L with line
[linePath moveToPoint:point1];
[linePath addToPoint:point2];
[linePath addToPoint:point3];
line.path=linePath.CGPath;
// Configure the appearence of the line
line.fillColor = Nil;
line.opacity = 1.0;
line.strokeColor = [UIColor whiteColor].CGColor;
Run Code Online (Sandbox Code Playgroud)
对此有任何想法将非常感激.
你可以试试这个吗 它对我的工作
CAShapeLayer *line = [CAShapeLayer layer];
UIBezierPath *linePath=[UIBezierPath bezierPath];
[linePath moveToPoint:CGPointMake(startx, starty)];
[linePath addLineToPoint:CGPointMake(endx, endy)];
line.lineWidth = 10.0;
line.path=linePath.CGPath;
line.fillColor = shapecolor.CGColor;
line.strokeColor = shapecolor.CGColor;
[[self.view layer] addSublayer:line];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9947 次 |
| 最近记录: |