Search code examples
iospathcgpathuibezierpath

get info about a CGpath, UIBezierPath?


I have a series of paths, mostly straight lines, or almost straight lines. I'd like to categorize them as horizontal, vertical, diagonal, and also the direction in which they are drawn (up->down, down->up, left->right, right->left etc). some of the lines are L shaped, and I'd like that info too.

this can probably be done if i knew the endpoints of the path, but i don't know how to extract that info. Also, I need more than that for L shaped lines since the endpoints would indicate a diagonal. I've looked on all the reference pages, and can't find that sort of info. so, if you know that, or another way to get the information i'm looking for ... thanks


Solution

  • The only way you can access the underlying structure is using the CGPathApply method on it. You pass a C function that is passed each of the elements(CGPathElement) in the bezier path. You should be able to discern what type of line it is in that method.

    There is a good example on using CGPathApply. It's not exactly what you need but looks like a good starting point.