2011-08-23 17 views

回答

2

有沒有內置的方式來做到這一點。使用tintColor將始終使您獲得默認的「閃亮」外觀。另一種方法是使用here中描述的技術自行繪製條形圖,以獲得所需的外觀。

+1

FWIW,似乎大多數投票和接受的答案是**不是一個好主意,因爲它顯然(請參閱評論)在iOS5中不起作用。 UINavigationBar必須是子類,而不是用覆蓋'drawRect的類別擴展:' –

+0

爲什麼是子類?在iOS 5中,有一個方法'setBackgroundImage:forBarMetrics:'所以在你的類別中,爲什麼不先執行'respondsToSelector:'檢查然後使用適當的方法? –

0

我用簡單的方法類UINavigationBar的:

@implementation UINavigationBar (UINavigationBarWithoutShiny) 
- (void)drawRect:(CGRect)rect {} 
@end 

在此之後,我可以使用UINavigationBar的視圖的只是背景色:

self.navigationController.navigationBar.backgroundColor = [UIColor greenColor]; 
+0

它僅適用於iOS 4.x,適用於iOS5我使用setTintColor: – buh