在 iOS6 中,我使用这段代码制作我的 UIBarButtonItem:
UIBarButtonItem* validate = [[UIBarButtonItem alloc]initWithTitle:@"MyTitle" style:UIBarButtonItemStylePlain target:self action:@selector(actionValidate)];
[validate setTintColor:[UIColor orangeColor]];
self.navigationItem.rightBarButtonItem = validate;
它在 iOS6 中工作正常,但在 iOS7 中,按钮的颜色只有在您按下它时才会改变。我该如何解决这个问题?
最佳答案
在 iOS7 中,如果你需要改变 navigationBar
按钮的颜色,你必须为 navgationBar
设置 tintColor
而不是特定的 barButton
不再。
navigationController.navigationBar.tintColor = [UIColor orangeColor];
编辑:这适用于 iOS7,您需要进行检查:
float systemVersion = [[[UIDevice currentDevice] systemVersion] floatValue];
if (systemVersion >= 7.0)
{
navigationController.navigationBar.tintColor = [UIColor orangeColor]
}
关于ios7 - UIBarButtonItem setTintColor 在 iOS7 上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19131481/