iphone - Stroke and Fill not working together - ObjectiveC -


this question has answer here:

i have shape drawing in drawrect method of uiview.

this code:

- (void)drawrect:(cgrect)rect {     cgcontextref context = uigraphicsgetcurrentcontext();      cgcontextsetfillcolorwithcolor(context, [[uicolor browncolor] cgcolor]);     cgcontextaddarc(context, 50, 50, 50, 342.0 * (m_pi / 180), 90.0 * (m_pi / 180), 1);      cgcontextsetfillcolorwithcolor(context, [[uicolor blackcolor] cgcolor]);     cgcontextfillpath(context);     cgcontextsetstrokecolorwithcolor(context, [[uicolor whitecolor] cgcolor]);     cgcontextstrokepath(context); } 

only first function (between fill , stroke) works.

if stroke first, fill doesn't work.

how can solve this?

why set 2 fillcolor ? want cgcontextdrawpath() function instead of calling both cgcontextfillpath() , cgcontextstrokepath.

cgcontextref context = uigraphicsgetcurrentcontext(); cgcontextsetfillcolorwithcolor(context, [[uicolor browncolor] cgcolor]); cgcontextaddarc(context, 50, 50, 50, 342.0 * (m_pi / 180), 90.0 * (m_pi / 180), 1); //    cgcontextsetfillcolorwithcolor(context, [[uicolor blackcolor] cgcolor]); cgcontextsetstrokecolorwithcolor(context, [[uicolor redcolor] cgcolor]); cgcontextdrawpath(context, kcgpathfillstroke); 

Comments