ios7 - UIBarButtonItem setTintColor 在 iOS7 上不起作用

标签 ios7 uibarbuttonitem uicolor

在 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/

相关文章:

ios - Alpha 不更新 - UIColor

java - 如何从 native iOS 和/或 Android 应用程序触发转换像素/跟踪像素?

authentication - coinbase oauth2 有时无法更新访问 token (使用刷新 token )

iphone - 更改 xcode 中的占位符文本

ios - 无法将 UIBarButtonItem 添加到工具栏

ios - 禁用导航栏按钮项

iOS7 侧边菜单状态栏颜色过渡。如在 iOS7 Facebook 应用程序中

ios - UIBarButtonItem 色调颜色与设备上的颜色不同

ios - iOS背景颜色-纯色

ios - HSV 转换的错误结果?