Why does setting the background image of the UINavigationBar affect the size of the navigation bar?

I am doing something like this:

UIImage *barBackgroundImage = [UIImage imageNamed:@"myImage.png"];
[[UINavigationBar appearance] setBackgroundImage:
                                    backgroundImage
                                   forBarMetrics:UIBarMetricsDefault];

And the result of the UINavigationBar is much larger than the standard navigation bar. I know that my image size can be a problem. Is there any way to take care of this programmatically?

+5
source share
2 answers

This is how I set the background image UINavigationController navigationBar.

[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"navbar.png"] forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setTintColor:LIGHTBROWN];

navbar.pngamounts to 320x44and respectively 640x88for navbar@2x.png.

+4
source

Follow this link to make your code compatible with iOS4, 5 and 6: http://robert-varga.com/?p=735

Photoshop 320x44 640x88 ( )

+2

All Articles