ipad - change 3 navigation bar background with different image -
i have 3 navigation controller , want change each background using different image. implement category extends uinavigationbar :
- (void)drawrect:(cgrect)rect { uiimage *image = [uiimage imagenamed:@"background.png"]; [image drawinrect:cgrectmake(0, 0, self.frame.size.width, self.frame.size.height)];}
@end
but make every navigation bar have same background image. , try implement code :
- (void)viewdidload { [super viewdidload]; self.navigationcontroller.navigationbar.tintcolor = [uicolor blackcolor]; uiimageview *backgroundview = [[uiimageview alloc] initwithimage:[uiimage imagenamed:@"background.png"]]; [self.navigationcontroller.navigationbar insertsubview:backgroundview atindex:0]; [backgroundview release];
}
in every controller each background show tintcolor, not image...what should do???
and how if want in tabbarcontroller??
on each of views, implement following in viewwillappear:
method
#import <quartzcore/quartzcore.h> ... - (void)viewwillappear:(bool)animated { self.navigationcontroller.navigationbar.layer.contents = (id)[uiimage imagenamed:@"yourimagebghere"].cgimage; }
cheers, rog
Comments
Post a Comment