ios - CGContextClipToMask does not clip -


this code results in image below. far understand cgcontextcliptomask, red rectangle should not visible, since outside of clipped area. missing here? help!

cgcontextref context = uigraphicsgetcurrentcontext(); cgcontextsetfillcolorwithcolor(context, [uicolor blackcolor].cgcolor); cgcontextfillrect(context, rect); cgcontextsetlinewidth(context, 20); cgcontextsetstrokecolorwithcolor(context, [uicolor whitecolor].cgcolor);  // draw partial circle uibezierpath *arc   = [uibezierpath bezierpathwitharccenter:center radius:radius startangle:startangle endangle:endangle clockwise:no]; cgcontextaddpath(context, [arc cgpath]); cgcontextstrokepath(context);  // create mask cgimageref mask = cgbitmapcontextcreateimage(context); self.maskcreated(mask);  // save state cgcontextsavegstate(context);  // clip mask cgcontextcliptomask(context, rect, mask);  // draw test rect cgcontextsetfillcolorwithcolor(context, [uicolor redcolor].cgcolor); cgcontextfillrect(context, cgrectmake(0, 0, 100, 100));  // restore state cgcontextrestoregstate(context); 

code result

actually don't understand concern, can hide rectangle in method this:

// draw test rect              cgcontextsetfillcolorwithcolor(context, [uicolor redcolor].cgcolor);  cgrect rect = cgrectzero; cgcontextfillrect(context, rect); 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -