iphone - How to make my navigationbar,and toolbar at the bottom to be a single color? -
i have application in using both navigation bar,and toolbar(at bottom).both having shade center bottom.this how creating toolbar`
[self.navigationcontroller settoolbarhidden:no animated:yes]; self.navigationcontroller.toolbar.barstyle = uibarstyleblackopaque; self.navigationcontroller.toolbar.frame=cgrectmake(0, [[uiscreen mainscreen] bounds].size.height -12, [[uiscreen mainscreen] bounds].size.width,30); self.navigationcontroller.toolbar.tintcolor=[uicolor colorwithpatternimage:[uiimage imagenamed:@"top_bar.png"]];
and doing navigation bar this
uiimage *navbar = [uiimage imagenamed:@"top_bar.png"]; [[uinavigationbar appearance] setbackgroundimage:navbar forbarmetrics:uibarmetricsdefault];
` can point me in going wrong?
i think easiest way create 1x1 uiimage , set background image navigation bar , toolbar. eliminate gradient , make both bars 1 solid color of choosing. here's example:
uiimage *image = [self imagewithcolor:[uicolor redcolor]]; [[uinavigationbar appearance] setbackgroundimage:image forbarmetrics:uibarmetricsdefault]; [[uitoolbar appearance] setbackgroundimage:image fortoolbarposition:uitoolbarpositionany barmetrics:uibarmetricsdefault]; - (uiimage *)imagewithcolor:(uicolor *)color { cgrect rect = cgrectmake(0.0f, 0.0f, 1.0f, 1.0f); uigraphicsbeginimagecontext(rect.size); cgcontextref context = uigraphicsgetcurrentcontext(); cgcontextsetfillcolorwithcolor(context, [color cgcolor]); cgcontextfillrect(context, rect); uiimage *image = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext(); return image; }
and if want rid of shadow cast beneath navigation bar, works me:
[self.navigationcontroller.navigationbar setclipstobounds:yes];
Comments
Post a Comment