I need to paint a series of path in a CGContext as a block. These path are drawn by the user so I can not determine their direction. I use the following code snippet to draw the path:
CGContextSaveGState(context);
UIBezierPath *fillPath = [ UIBezierPath bezierPath ];
for ( UIBezierPath *path in arrayOfPaths ) {
[ fillPath appendPath:path ];
}
CGContextAddPath(context, fillPath.CGPath );
CGContextSetFillColorWithColor( context, [[UIColor GreenColor ] colorWithAlphaComponent:0.3 ].CGColor );
CGContextFillPath(context);
However if the paths were created in reverse directions the resulting drawing seems to produce a drawing where the overlapping section is knocked out, equivalent of setting the even-odd rule to Yes.
Any suggestions?