2013-09-25 218 views
-1

有誰知道,我如何才能使iOS7中的UINavigationBar全黑?默認它是白色的,我需要黑色。IOS7 UINavigationBar黑色背景

+0

可能複製[如何更改iOS 7中的導航欄顏色?](http://stackoverflow.com/questions/18929864/how-do-i-change-the-navigation-bar-color-in-ios-7 ) – Rajneesh071

回答

0

下面是編程創建了一個黑色的UIImage,並將其設置爲UINavigationBar的外觀的一種方式:

UIView *background = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 568, 44)]; 
background.backgroundColor = [UIColor blackColor]; 
UIGraphicsBeginImageContext(background.frame.size); 
CGContextRef context = UIGraphicsGetCurrentContext(); 
[background.layer renderInContext:context]; 
UIImage *backgroundImage = UIGraphicsGetImageFromCurrentImageContext(); 
UIGraphicsEndImageContext();   

[[UINavigationBar appearance] setBackgroundImage:backgroundImage 
              forBarMetrics:UIBarMetricsDefault]; 
0

找到了我自己。進入故事情節,設計師,選擇視圖控制器,請從屬性推斷督察,改變上欄「不透明的黑色導航欄」

+0

Interface-Builder不幸的只是提供了一個模擬的外觀(查看標籤,它說「Simulated Metrics」)。您需要在代碼(每個ViewController)或您的info.plist(每個應用程序)中設置它。 – auco

1

如果你的目標只適用於iOS 7,您可以使用:

[[UINavigationBar appearance] setBarTintColor:(UIColor *)];