在一种功能中,我正在使用UIBezierPath绘制曲线。在一种情况下,我需要将UIBezierPath相对于常量(在设备格局x值512.0中)分成多个部分,我不确定是否可能。任何做同样的事情。请帮助我摆脱这种情况。
提前致谢。

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

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

最佳答案

每个bezierpath都有两个点(起点和终点)。

接触开始事件

    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行。(即)x1 = 500,x2 = 700,y1 = 250,y2 = 500和新的x =(x1 + x2 / 2)y = (y1 + y2 / 2)(根据您的要求计算新点)调用drawRect画线。

关于iphone - 试图划分UIBezierPath,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10717203/

10-14 23:14