0

我正在使用以下代码在导航栏上显示按钮:

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 上,按钮采用导航栏颜色。一旦我点击任何按钮,所有按钮的颜色都会变为浅色。

我搜索了很多小时,但找不到解决方案。

谁能帮我。

4

3 回答 3

0

// 条形按钮正常状态标题颜色。

[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];
于 2014-11-06T10:52:43.580 回答
0

尝试执行以下操作:

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

在 iOS7 中,您需要设置tintColor更改栏按钮的色调。

于 2013-10-04T16:16:44.577 回答
0

我能够解决这个错误。我为导航栏使用了背景图像,并使用 BarButton 颜色作为导航栏的色调。我使用了以下代码:

self.navigationController.navigationBar.tintColor = [UIColor lightGrayColor]; 
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"BarBackground.png"] forBarMetrics:UIBarMetricsDefault]; 
于 2013-11-08T12:06:09.570 回答