You don't clear self.drawingImageView.image
before you start doing your redraw of the remaining paths. So, all you're currently doing is redrawing the lines over the old lines.
What you should do is:
- Create a single new context and draw all of the lines into it
- Don't draw the old image into this new context
- Don't use GCD to queue updates to this context, just do it inline (in the background if you want)
then, at the end, get the new image from the context (image = UIGraphicsGetImageFromCurrentImageContext()
) and save it in self.drawingImageView.image = image;
Pseudo code:
// create a new bitmap image context
UIGraphicsBeginImageContextWithOptions(...
ctx = UIGraphicsGetCurrentContext();
for (NSArray *subArray in self.drawingPathArray) {
// get the path and colour
CGContextSetStrokeColor(ctx, ...
CGContextAddPath(ctx, ... (path from bezier)
CGContextStrokePath(ctx);
}
// create image
image = UIGraphicsGetImageFromCurrentImageContext();
self.drawingImageView.image = image;