使用CAShape图层绘制两条平行线 [英] Draw two parallel line using CAShape Layer

查看:166
本文介绍了使用CAShape图层绘制两条平行线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在绘制一条直线,

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?

或者是否有任何代码可以获取该特定行的接触点。实际上,当我在两条线之间触摸时可以得到触摸点,并且通过 CGPathContainsPoint 方法可以在两条线之间获得触摸点,因此我想在此处创建两条平行线。

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.

推荐答案

线几何

b-班次。并且需要转换坐标

b - shift. and you need convert coordinates

这篇关于使用CAShape图层绘制两条平行线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆