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!!

4

2 回答 2

0

也许这是一个图层光栅化问题:

检查是否有:

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

在您的代码中的某处并尝试评论这些行。

(这些线条通常与阴影相关联,以提高显示时的性能)。

于 2014-12-10T12:52:10.020 回答
0

一个快速的解决方案是转到 NIB 文件并选择UINavigationControler-> Size Inspector -> TurnOff Autoresizing。

在此处输入图像描述

于 2013-05-15T12:29:15.383 回答