Drawing a bezier curve between a set of given points

后端 未结 6 1647
春和景丽
春和景丽 2021-02-13 13:40

What is the best way to draw a bezier curve, in iOS application, that passes through a set of given points

6条回答
  •  无人及你
    2021-02-13 14:32

    You can be much more efficient by using the CGPointFromString method:

     NSArray *pointArray = @[@"{3.0,2.5}",@"{100.0,30.2}", @"{100.0,200.0}", @"{3.0,200.0}"];
    
    // draw the path
    UIBezierPath *aPath = [UIBezierPath bezierPath];
    for (NSString *pointString in pointArray) {
        if ([pointArray indexOfObject:pointString] == 0)
            [aPath moveToPoint:CGPointFromString(pointString)];
        else
            [aPath addLineToPoint:CGPointFromString(pointString)];
    }
    [aPath closePath];
    

提交回复
热议问题