I am working on a graphical application, I have UIBezeirPath with which I draw in touchhesMoved and convert it to CGPath, and then draw CGlayer,
Here is my code
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { self.currentPath = [[DrawingPath alloc] init]; if(m_eraseButtonClicked) { [self.currentPath setPathColor:[UIColor backgroundColor]]; } else { [self.currentPath setPathColor:self.lineColor]; } CGPathRef cgPath = self.currentPath.path.CGPath; mutablePath = CGPathCreateMutableCopy(cgPath); } - (void)Erase { CGContextRef layerContext = CGLayerGetContext(self.DrawingLayer); CGContextSetBlendMode(layerContext,kCGBlendModeClear); CGContextSetLineWidth(layerContext, self.eraseWidth); CGContextBeginPath(layerContext); CGContextAddPath(layerContext, mutablePath); CGContextStrokePath(layerContext); } - (void)UndoRedoFunction {
Erase works fine, because I use blendMode Clear, but when undoing / Redo, as you can see, I get pathColor from the path and stroke it with blenModeNormal, I see a white line,
Below image, after I write-> erase-> undo-> repeat

ios uikit core-graphics uibezierpath cgcontext
Ranjit Feb 26 '14 at 6:11 2014-02-26 06:11
source share