2014-02-06 4 views

답변

3

CGPathApplyCGPathApplierFunction을 사용하면됩니다.

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. 

} 
과 같을 것
관련 문제