UIBarButtonItem setTintColor在iOS7上不起作用 [英] UIBarButtonItem setTintColor doesn't work on iOS7

查看:394
本文介绍了UIBarButtonItem setTintColor在iOS7上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iOS6中,我使用此代码制作我的UIBarButtonItem:

In iOS6, I used this code to make my UIBarButtonItem:

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

它在iOS6中工作正常,但在iOS7中,按钮的颜色只有在你按下它时才会改变。 。我该如何解决这个问题?

It works fine in iOS6 but in iOS7, the color of the button changes only when you push it.. How can I fix this?

推荐答案

在iOS7中你需要更改 navigationBar 按钮颜色,您必须为 navgationBar 设置 tintColor 而不是特定 barButton 了。

In iOS7 you if you need to change the navigationBar buttons color, you must set tintColor for the navgationBar not the for specific barButton any more.

navigationController.navigationBar.tintColor = [UIColor orangeColor];

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

this works in iOS7, you need to do the check:

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

这篇关于UIBarButtonItem setTintColor在iOS7上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆