2013-12-13 87 views
0

我試圖更改導航欄中後退按鈕的箭頭的顏色。我已經能夠改變文字顏色,但不能改變箭頭。這裏是我的代碼來改變文字顏色:更改後退按鈕中箭頭的顏色iOS

[[UIBarButtonItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: 
                  [UIColor whiteColor], UITextAttributeTextColor, 
                  nil] forState:UIControlStateNormal]; 

如果任何人都可以就如何改變箭頭coliur勸我,那將是非常有幫助!

回答

2

您可以使用這樣的圖像變回按鈕的背景:

UIImage *buttonBack30 = [[UIImage imageNamed:@"button_back_textured_30"] 
    resizableImageWithCapInsets:UIEdgeInsetsMake(0, 13, 0, 5)]; 
UIImage *buttonBack24 = [[UIImage imageNamed:@"button_back_textured_24"] 
    resizableImageWithCapInsets:UIEdgeInsetsMake(0, 12, 0, 5)]; 
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:buttonBack30 
    forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; 
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:buttonBack24 
    forState:UIControlStateNormal barMetrics:UIBarMetricsLandscapePhone]; 

來源:RAYWENDERLICH

如果你不想使用圖片,您可以更改導航欄的tintcolor ,因爲它決定了酒吧按鈕項的文字顏色:

[[UINavigationBar appearance] setTintColor:[UIColor yourColor]]; 
+0

恐怕非圖像不適用於ios 7? –

+0

它應該工作。嘗試一次。 –

相關問題