2014-01-30 51 views
4

我對iOS7的navigationController中的所有這些顏色設置感到十分困惑。有人能告訴我所有這些事情有什麼確切的區別嗎?我試圖弄清楚其中的一些,但不確定我是否正確。iOS7這些顏色有什麼區別,「barTintColor,tintColor,backgroundColor,UITextAttributeTextColor」?

謝謝!

self.navigationController.navigationBar.barTintColor=[UIColor redColor];//??? 

self.navigationController.navigationBar.backgroundColor=[UIColor greenColor];//??? 

self.navigationController.navigationBar.tintColor=[UIColor whiteColor];//the text colour of backButton of the navigationBar??? 

self.navigationController.navigationBar.titleTextAttributes = @{UITextAttributeTextColor:[UIColor blueColor]};//the text color of the title of the navigationBar 

[self.navigationItem.rightBarButtonItem setTitleTextAttributes:@{UITextAttributeTextColor:[UIColor greyColor]} forState:UIControlStateNormal];//the text colour of the customised rightButton in the navigationBar 

回答

10

以下是上述的區別:

barTintColor:着色顏色應用到導航欄背景。

的backgroundColor:改變的導航欄

tintColor的背景色:着色顏色應用到導航項目和欄按鈕的項目。

UITextAttributeTextColor:文本屬性字典中文本顏色的關鍵字。相應的值是UIColor的一個實例。 Available in iOS 5.0 and later.Deprecated in iOS 7.0.這是一個easy fix。只要改變UITextAttributeTextColor to NSForegroundColorAttributeName

以下是詳細信息:https://developer.apple.com/library/ios/documentation/uikit/reference/UINavigationBar_Class/Reference/UINavigationBar.html

+0

那麼究竟是什麼色調的顏色?我認爲這只是項目的顏色。 – user3247270

+0

tintColor是「應用於導航項目和酒吧按鈕項目的色調顏色。」它適用於barItems和按鈕。 –