2014-02-06 1 views

ответ

3

Вы можете сделать это, используя CGPathApply и CGPathApplierFunction.

NSMutableArray *thePoints = [[NSMutableArray alloc] init]; 
UIBezierPath *aPath; 
CGPath theCGPath = aPath.CGPath; 
CGPathApply(theCGPath, thePoints, MyCGPathApplierFunc); 

Что это такое - передать функцию Applier каждому элементу пути. Вы можете получить список точек из каждого элемента внутри вашей функции и добавить их в thePoints.

Ваша функция наложения будет выглядеть как

void MyCGPathApplierFunc (void *info, const CGPathElement *element) { 
    NSMutableArray *thePoints = (NSMutableArray *)info; 

    CGPoint *points = element->points; 
    [thePoints addObject:[NSValue valueWithCGPoint:points[0]]]; 
    \\Only 1 point assuming it is a line 
    \\Curves may have more than one point in points array. Handle accordingly. 

}