Navigation bar background image

how can i set the image to the background of the navigation bar so that it is also in the background? now I have an image with a resolution of 320 pixels, but it compresses this image so that the left button is a standard button, and on the right side it is 5 pixels in standard blue. I want this image to be above the fuel width, and maybe I will make a darker back button later.

+3
source share
1 answer
@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

. , . , , , . .

EDIT: iOS 5

if ([self.navigationController.navigationBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)] )
{
    UIImage *image = [UIImage imageNamed:@"headerlogo.png"];
    [self.navigationController.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
}
+3

Source: https://habr.com/ru/post/1755759/


All Articles