0

I'm trying to customise the navigation bars throughout my app. The navigation controller has been created in IB. I used the following code to add a custom image to the bar. The image is 320 x 44 points. This code is in the AppDelegate in applicationDidFinishLaunchingWithOptions:

UIImage *navBackgroundImage = [UIImage imageNamed:@"Nav Image.png"];
    [[UINavigationBar appearance] setBackgroundImage:navBackgroundImage forBarMetrics:UIBarMetricsDefault];

The problem is that on the simulator, the bar now covers half the screen! And covers up a load of content. Ive tried messing around with the image dimensions in Photoshop and it helps, but their must be an easier way than messing around and rebuilding with trial and error?!!

Are there any convenience methods that set the size of the nav bar?

Any help much appreciated!!

Dave Thwaites
  • 160
  • 11
  • I think you mistakenly set the retina image instead of standard image for your navigation bar – Dinesh Raja May 15 '13 at 14:48
  • Image dimensions are very important while adding custom background image. Please check solution http://stackoverflow.com/questions/1692487/how-to-add-background-image-on-iphone-navigation-bar/42479477#42479477 – Aamir Feb 27 '17 at 06:59

2 Answers2

0

A quick solution is to go to the NIB file and select UINavigationControler -> Size Inspector -> TurnOff Autoresizing.

enter image description here

halfer
  • 19,824
  • 17
  • 99
  • 186
Yashesh
  • 1,799
  • 1
  • 11
  • 29
  • Thanks for your answer. No joy Im afraid. There doesn't seem to be any attributes at all to resize the nav bar when i select it. – Dave Thwaites May 15 '13 at 12:42
0

Maybe it is a layer Rasterization issue :

check if there is :

 layer.shouldRasterize = YES;
 layer.rasterizationScale = [UIScreen mainScreen].scale;

somewhere in your code and try commenting those lines.

(these lines are often linked to shadows to improve the performance when displaying them).

ZpaceZombor
  • 877
  • 1
  • 10
  • 8