navigation bar background image
how can i set an image into the background of the navigation-bar, so that is also in the background of the back-button ? now i have an image with a with of 320 pixels, but it shrinks that image so, that the left back-button is the standard-开发者_开发百科button and on the right side there are 5 pixels in the standard-blue. i want that this image is over the fuel width and maybe i will do a darker back-button later.
@implementation UINavigationBar (UINavigationBarCategory)
- (void)drawRect:(CGRect)rect
{
UIImage *image = [UIImage imageNamed: @"titlebar.png"];
[image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}
@end
I have found this snippet. so the image is on every navigationbar as background and i can set the old image as the view in the middle. maybe I dont understand why that works, but it works. sorry for the dumb question.
EDIT: For iOS 5
if ([self.navigationController.navigationBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)] )
{
UIImage *image = [UIImage imageNamed:@"headerlogo.png"];
[self.navigationController.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
}
精彩评论