I have the exact same problem. It's not working on iOS 5.0 but it does work on iOS 5.1 and more. I'm still looking for the fix.
UPADTE: I fixed the issue using UIBezierPath. You can draw all your paths using Besier and then convert it to CGPath this way:
UIBezierPath *path = [[UIBezierPath alloc] init];
// Add all the lines you need
[path addLineToPoint:p];
// Or points
[path moveToPoint:p];
// Append paths
[path appendPath:linePath];
// Make a CGPath from UIBezierPath
CGPath myCGPath = path.CGPath;
Try this code, it should work but I haven't tested it:
- (void)makeCGPath
{
UIBezierPath *path = [[UIBezierPath alloc] init];
if (lines && lines.count>0)
{
for (int i = 0; i < lines.count; i++)
{
UIBezierPath *linePath = [[UIBezierPath alloc] init];
NSArray *tempArray = [lines objectAtIndex:i];
CGPoint p = [[tempArray objectAtIndex:0]CGPointValue];
[linePath addLineToPoint:p];
for (int j = 1; j < tempArray.count; j++)
{
p = [[tempArray objectAtIndex:j]CGPointValue];
[linePath addLineToPoint:p];
}
[path appendPath:linePath];
}
}
if (points && points.count > 0)
{
UIBezierPath *pointPath = [[UIBezierPath alloc] init];
CGPoint p = [[points objectAtIndex:0]CGPointValue];
[pointPath moveToPoint:p];
for (int i = 1; i < points.count;i++ )
{
p = [[points objectAtIndex:i]CGPointValue];
[pointPath moveToPoint:p];
}
[path appendPath:pointPath];
}
drawPath = path.CGPath;
[self setNeedsDisplay];
[lines removeAllObjects];
[points removeAllObjects];
}