ios - Proper use of eraser tool above the image while drawing? -


i have 1 uiview in have draw image. on view drawing pen tool, rectangle tool , update new image , draw. acedrawingview

i facing 1 issue eraser tool. when use eraser background image color gone. please check screenshot.

enter image description here

in above image black portion pen drawing , white portion eraser drawing. want when user eraser drawing not clear background image. drawing.

redraw image code

    - (void)updatecacheimage:(bool)redraw {     uigraphicsbeginimagecontextwithoptions(self.bounds.size, no, 0.0);     if (redraw) {         // erase previous image         self.image = nil;          // load previous image (if returning screen)         [[self.prev_image copy] drawinrect:cgrectmake(0, 0, self.frame.size.width, self.frame.size.height)];          // need redraw lines         (id<acedrawingtool> tool in self.patharray) {             [tool draw];         }      } else {         // set draw point         [self.image drawatpoint:cgpointzero];         [self.currenttool draw];     }      // store image     self.image = uigraphicsgetimagefromcurrentimagecontext();     uigraphicsendimagecontext(); } 

eraser tool drawing

    - (void)draw {     cgcontextref context = uigraphicsgetcurrentcontext();      cgcontextaddpath(context, self.path);     cgcontextsetlinecap(context, kcglinecapround);     cgcontextsetlinewidth(context, self.linewidth);     cgcontextsetstrokecolorwithcolor(context, self.linecolor.cgcolor);     cgcontextsetblendmode(context, kcgblendmodenormal);     cgcontextsetalpha(context, self.linealpha);     cgcontextstrokepath(context); } 

this because using self.linecolor.cgcolor guess last chosen color, white in case. try replacing current color [uicolor clearcolor] , add line of code cgcontextsetblendmode(uigraphicsgetcurrentcontext(), kcgblendmodeclear);


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -