1

我想從模態視圖設置NavigationController,但我無法弄清楚如何使用界面生成器設置佈局選項。這是我正在使用的代碼。從Modal View設置NavigationController並在界面構建器中設置佈局?

//Create the view you want to present modally 
UIViewController *modalView = [[UIViewController alloc] init]; 
//Create a new navigation stack and use it as the new RootViewController for it 
UINavigationController *nav = [[UINavigationController alloc]   
initWithRootViewController:modalView]; 
//Present the new navigation stack modally 
[self presentModalViewController:nav animated:YES]; 
//Release 
[modalView release]; 
[nav release]; 

反正有設置在Interface Builder中navigationcontroller的佈局選項?我試着設置使用

nav.navigationBar.tintColor = [UIColor colorWithRed:128 green:0 blue:0 alpha:1]; 

的顏色,而是導致在明亮的紅色,而不是栗色此RGB組合被認爲導致英寸

這將是對我來說容易得多,如果我能控制的導航控制器選項從接口生成器,這是可能的這個設置?

+0

您只能在IB的主視圖中設置導航欄的色調顏色。如果你想改變視圖之間的色調,你必須對它進行硬編碼。 – rishi 2012-01-08 06:33:31

回答

0

既然你以編程方式創建這些意見,沒有什麼接口生成器來設置。但是,您可以通過編程設置色調顏色。你的問題是,UIColor初始化器在1.0f和0.0f之間取得顏色強度的浮動。你的128只是夾在1.0f,因此明亮的紅色。試試這個:

nav.navigationBar.tintColor = [UIColor colorWithRed:0.5f blue:0 green:0 alpha:1.0f]; 

這應該會給你一個更接近你正在尋找的顏色。

+0

謝謝。現在我可以硬編碼我需要的一切 – davis 2012-01-08 06:48:56

0

您無法使用界面構建器更改色調顏色。你必須硬編碼它,就像你在你的問題中暗示的一樣。

您有兩種選擇。

  1. 使用RGB值,使用不同的值alpha得到栗色,然後使用它。
  2. 創建栗色的背景(using paint or photoshop),並設置爲你的background view.