2013-10-04 314 views
0

我使用下面的代碼顯示導航欄上的按鈕:欄按鈕的顏色變化7

UIBarButtonItem *barButton = [[UIBarButtonItem alloc] initWithTitle:@"Save" style:UIBarButtonItemStyleDone target:self action:@selector(saveData:)]; 
    barButton.tintColor = [UIColor colorWithRed:170/255.0 green:210/255.0 blue:87/255.0 alpha:1.0]; 
    barButton.tag = 001; 
    [buttonArray addObject:barButton]; 

此代碼在iOS 5和6,但在iOS 7鍵以導航欄工作正常顏色。 一旦我點擊任何按鈕,然後所有按鈕顏色變爲色調顏色。

我搜索了很多小時,但無法找到解決方案。

任何人都可以幫助我。

+0

我能夠解決這個錯誤。 我使用了導航欄的背景圖片,並且使用BarButton顏色作爲導航欄的色調顏色。我使用了以下代碼: self.navigationController.navigationBar.tintColor = [UIColor lightGrayColor]; [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@「BarBackground.png」] forBarMetrics:UIBarMetricsDefault]; –

回答

0

嘗試做以下:

navigationController.navigationBar.tintColor = [UIColor colorWithRed:170/255.0 green:210/255.0 blue:87/255.0 alpha:1.0]; 

在iOS7需要設置tintColor改欄按鈕色彩。

0

我能夠解決這個錯誤。我使用導航欄的背景圖像,並使用BarButton顏色作爲導航欄的着色顏色。我使用了以下代碼:

self.navigationController.navigationBar.tintColor = [UIColor lightGrayColor]; 
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"BarBackground.png"] forBarMetrics:UIBarMetricsDefault]; 
0

// Bar button Normal State title color。

[cancelBarButton setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor], NSFontAttributeName:[UIFont normalStateFont]} forState:UIControlStateNormal]; 

// Bar button Highlighted State title color. 
[cancelBarButton setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor yellowColor], NSFontAttributeName:[UIFont yourHighlightedFont]} forState:UIControlStateHighlighted];