Draw two parallel line using CAShape Layer

浪子不回头ぞ 提交于 2019-12-08 08:15:12

问题


I am drawing single line by

CAShapeLayer *lineShape = nil;
CGMutablePathRef linePath = nil;
linePath = CGPathCreateMutable();
lineShape = [CAShapeLayer layer];

lineShape.lineWidth = 1.0f;
lineShape.lineCap = kCALineJoinMiter;
lineShape.strokeColor = [[UIColor redColor] CGColor];


CGPathMoveToPoint(linePath, NULL, x, y);
CGPathAddLineToPoint(linePath, NULL, toX, toY);

lineShape.path = linePath;
CGPathRelease(linePath);

[myView.layer addSublayer:lineShape];

i want to draw a parallel line to this line . Any idea or calculation?

or is there any code for getting touch point of this particular line . actually i can get touch point when i touch between two lines and from CGPathContainsPoint method i can get touch point between two lines , hence i want to create two parallel lines here.


回答1:


Line geometry

b - shift. and you need convert coordinates



来源:https://stackoverflow.com/questions/9229579/draw-two-parallel-line-using-cashape-layer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!