views:

69

answers:

1

Is there a way to move a path on screen by (x,y) pixels using directly a CGPathRef instead of walking through its points and lines again in drawRect method? I want to be reusing my old CGPathRef when I want to move it on screen instead of recreating it with new pixels.

A: 

Depending on your needs, you could just translate the drawing context via CGContextTranslateCTM before drawing your path (then restore the old context, either with push/popping contexts, or inverting the translation). You might also like CGPathApply, which will call a function for every path element in the path (so you can translate the points by hand).

Adam Wright
first of all my path just contains points and lines and I use only the functions ..MoveToPoint and ..AddLineToPoint methods to draw them. From the performance perspective does it differ to perform a for loop with the points of the path than using CGPathApply method?
cocoatoucher