How can I redraw a stored CGPath as a Bezier path if the original CGPoints were not stored?
This is the code, but it does not work (the path is redrawn in standard mode rather than in Bezier mode):
CGMutablePathRef UpathFREEHAND = CGPathCreateMutable();
CGPoint firstPointFH = [[pointArray objectAtIndex:0] CGPointValue];
CGPathMoveToPoint(UpathFREEHAND, NULL, firstPointFH.x, firstPointFH.y);
for (int i = 0; i < [pointArray count]; i++)
{
CGPathAddLineToPoint(UpathFREEHAND, NULL, [[pointArray objectAtIndex:i] CGPointValue].x,
[[pointArray objectAtIndex:i] CGPointValue].y);
}
CGMutablePathRef _TempPathForUndo = UpathFREEHAND;
//Add PATH object to array
[UPath addObject:CFBridgingRelease(_TempPathForUndo)];
//Load PATH object from array
_TTempPathForUndo = (__bridge CGMutablePathRef)([UPath objectAtIndex:i]);
// Now create the UIBezierPath object.
UIBezierPath *bp;
bp = [UIBezierPath bezierPath];
bp.CGPath = _TTempPathForUndo;
CGContextAddPath(context, bp.CGPath);
//Color, Brush Size parameters, Line cap parameters..
CGContextStrokePath(context);
You can use the following method from
UIBezierPath:The reuse of a
CGPathis valid. Check this example addingTestViewin aUIViewControllerand linking aUIButtonto force the redraw when clicking on it with[_testView setNeedsDisplay]: