iphone - Using drawInRect inside a c method not working -


i have code, draw text inside (so far) simple button:

uiimage *buttonimage(cgrect bounds, uicolor *fillcolor, nsstring *title) {      uigraphicsbeginimagecontextwithoptions(bounds.size, no, 0);      cgcontextref context = uigraphicsgetcurrentcontext();      cgcontextsetfillcolorwithcolor(context, fillcolor.cgcolor);     cgcontextfillrect(context, bounds);      uiimage *image = uigraphicsgetimagefromcurrentimagecontext();      cgcontextsetfillcolorwithcolor(context, [uicolor whitecolor].cgcolor);      [title drawinrect:bounds withfont:panelbuttonfont];      uigraphicsendimagecontext();      return image; } 

the problematic part drawinrect. it's not drawing text. font correct, , i've tested normal font code there, it's not that. think perhaps doesn't realise want draw onto image it's producing?

just change order , image after draw text:

uiimage *buttonimage(cgrect bounds, uicolor *fillcolor, nsstring *title) {  uigraphicsbeginimagecontextwithoptions(bounds.size, no, 0);  cgcontextref context = uigraphicsgetcurrentcontext();  cgcontextsetfillcolorwithcolor(context, fillcolor.cgcolor); cgcontextfillrect(context, bounds);  cgcontextsetfillcolorwithcolor(context, [uicolor whitecolor].cgcolor);  [title drawinrect:bounds withfont:panelbuttonfont];  uiimage *image = uigraphicsgetimagefromcurrentimagecontext();  uigraphicsendimagecontext();  return image; 

}


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -