UIBarButtonItem setTintColor在iOS7上不起作用

Ant*_*ony 3 uibarbuttonitem uicolor ios7

在iOS6中,我使用此代码来创建我的UIBarButtonItem:

UIBarButtonItem* validate = [[UIBarButtonItem alloc]initWithTitle:@"MyTitle" style:UIBarButtonItemStylePlain target:self action:@selector(actionValidate)];
    [validate setTintColor:[UIColor orangeColor]];
    self.navigationItem.rightBarButtonItem = validate;
Run Code Online (Sandbox Code Playgroud)

它在iOS6中运行良好,但在iOS7中,按钮的颜色只有在你推动时才会改变.我该如何解决这个问题?

nul*_*ull 5

在iOS7中,如果需要更改navigationBar按钮颜色,则必须设置tintColornavgationBar不再具体barButton.

navigationController.navigationBar.tintColor = [UIColor orangeColor];
Run Code Online (Sandbox Code Playgroud)

编辑:这适用于iOS7,您需要进行检查:

float systemVersion = [[[UIDevice currentDevice] systemVersion] floatValue];
if (systemVersion >= 7.0)
{
    navigationController.navigationBar.tintColor = [UIColor orangeColor]
}
Run Code Online (Sandbox Code Playgroud)