iphone - Custom navigation bar buttons with system icons and images -
i'm trying figure out how add custom background image navigationbar buttons use system icons, or image icons.
i've figured out how add background image navigationbar buttons text, i'm struggling figure out how accomplish icon buttons.
for text buttons followed tutorial: http://idevrecipes.com/2010/12/13/wooduinavigation/
how can create custom buttons w/ icons?
thanks!
u might this
@implementation uinavigationbar (uinavigationbarcategory) -(void)setbackgroundimage:(uiimage*)image{ if(!image) return; uiimageview *atabbarbackground = [[uiimageview alloc]initwithimage:image]; // atabbarbackground.frame = cgrectmake(0,0,self.frame.size.width,self.frame.size.height); atabbarbackground.frame = cgrectmake(0,0,self.frame.size.width * .6,self.frame.size.height); // [self addsubview:atabbarbackground]; // [self sendsubviewtoback:atabbarbackground]; [self insertsubview: atabbarbackground atindex: 0]; [atabbarbackground release]; } @end
it works fine me
also hav idea.
@implementation uinavigationbar (uinavigationbarcategory) - (void)drawrect:(cgrect)rect { // drawing code uiimage *img = [uiimage imagenamed: @"navbar_background.png"]; cgcontextref context = uigraphicsgetcurrentcontext(); cgcontextdrawimage(context, cgrectmake(0, 0, 320, self.frame.size.height), img.cgimage);
} @end
Comments
Post a Comment