回答

0

我有一个UINavigationController,我自定义如下:

首先,拿出一个44px高的图像作为背景的导航栏。 (在这种情况下,如果你想使用一个44px高的白色图像,即会做的伎俩---但它会看起来更漂亮,如果你使用某种类型的垂直梯度)

其次,使用以下代码在您的AppDelegatedidFinishLaunching方法中。 (图像被称为“background_44.png”。

// Set the background image for *all* UINavigationBars 
    UIImage *gradientImage44 = [[UIImage imageNamed:@"background_44.png"] 
           resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)]; 

// Set the background image for *all* UINavigationBars 
    [[UINavigationBar appearance] setBackgroundImage:gradientImage44 
              forBarMetrics:UIBarMetricsDefault]; 
+0

或者你可以检查出此相关的问题:http://stackoverflow.com/questions/2706584/why-cant-i-set-a-custom-color-tint-for-the- UINavigationBar的 – bryanjclark 2012-02-07 23:27:20

+0

不将其设置为自定义颜色,它设置为白色 – adit 2012-02-08 00:04:53

0

我丢弃的代码在我的项目,工作得很好。甚至改变了酒吧的款式和颜色。没问题,这行代码是好的,有其他地方的问题。或它的一些疯狂的毛刺