uiview - UITabBarItem image created in code doesn’t appear -


i create following view in code, idea use image in uitableviewcell , uitabbaritem:

- (void)drawrect:(cgrect)rect {     // fill background white     cgcontextref context = uigraphicsgetcurrentcontext();      uicolor * whitecolor = [uicolor colorwithred:1.0                                            green:1.0                                             blue:1.0                                            alpha:1.0];      cgcontextsetfillcolorwithcolor(context, whitecolor.cgcolor);     cgcontextfillrect(context, self.bounds);      //// color declarations     uicolor* fillcolor = [uicolor colorwithred: 1.0                                          green: 1.0                                           blue: 1.0                                          alpha: 1.0];      uicolor* strokecolor = [uicolor colorwithred: 0.0                                            green: 0.0                                             blue: 0.0                                            alpha: 1.0];      //// big oval drawing     cgrect bigovalrect = cgrectmake(rect.origin.x+2,                                     rect.origin.y+5,                                     42.0,                                     42.0);      uibezierpath* bigovalpath = [uibezierpath bezierpath];      [bigovalpath addarcwithcenter: cgpointmake(cgrectgetmidx(bigovalrect), cgrectgetmidy(bigovalrect))                          radius: cgrectgetwidth(bigovalrect) / 2                      startangle: 40 * m_pi/180                        endangle: 320 * m_pi/180                       clockwise: yes];      [fillcolor setfill];     [bigovalpath fill];     [strokecolor setstroke];     bigovalpath.linewidth = 1;     [bigovalpath stroke];   } 

to create uiimage uiview using code:

#import <quartzcore/quartzcore.h>  + (uiimage *) imagewithview:(uiview *)view {     uigraphicsbeginimagecontextwithoptions(view.bounds.size, view.opaque, 0.0);     [view.layer renderincontext:uigraphicsgetcurrentcontext()];      uiimage * img = uigraphicsgetimagefromcurrentimagecontext();      uigraphicsendimagecontext();      return img; } 

everything works expected when use in uitableviewcells when set image of uitabbaritem see blue rectangle (ios7):

myicon *icon = [[myicon alloc] initwithframe:cgrectmake(0.0, 0.0, 50.0, 50.0)]; uiimage *tabimage =[self imagewithview:icon];  self.navigationcontroller.tabbaritem.image = tabimage; 

i guess related alpha of image how can fix it?

it wasn't problem related size of view alpha.

i fixed setting backgroundcolor (was whitecolor) , fillcolor to:

[uicolor clearcolor] 

and setting view opaque in initwithframe: method:

[self setopaque = no]; 

Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -