2013-10-04 316 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];