1

在一个功能中,我使用 UIBezierPath 来绘制曲线。在一种情况下,我需要将 UIBezierPath 分解为相对于常数的部分(在设备景观 x 值 512.0 中)。我不确定它是否可能。是否存在任何笏做同样的事情。请帮助我摆脱这种情况。提前致谢。

我在我的应用程序中用于绘图的一些代码片段:

    [bezierPath moveToPoint:mid1];
    [drawingBezier addQuadCurveToPoint:mid2 controlPoint:previousPoint1];
    [self setNeedsDisplay];
4

1 回答 1

5

每个贝塞尔路径都有两个点(起点和终点)。

在触摸开始事件

    UITouch *mytouch=[[touches allObjects] objectAtIndex:0];
    [myPath moveToPoint:[mytouch locationInView:self]];      // points (X1,y1)

在触摸移动事件

    UITouch *mytouch=[[touches allObjects] objectAtIndex:0];
   [myPath addLineToPoint:[mytouch locationInView:self]];   // points (X2,y2)

现在使用 (x1,x2) 和 (y1,y2) 值拆分 mypath 行。(ie) x1=500, x2= 700, y1=250, y2 = 500 和新 x = (x1+x2/2) y = (y1+y2/2) (根据您的要求计算新点)调用 drawRect 绘制线条。

于 2012-08-02T09:40:37.343 回答