Ios 如何改变酒吧按钮项目的颜色?

Ios 如何改变酒吧按钮项目的颜色?,ios,objective-c,colors,uibarbuttonitem,Ios,Objective C,Colors,Uibarbuttonitem,在我的详细视图控制器(导航控制器应用程序的一部分)中,我添加了自定义的“后退”按钮,如下所示: - (void)loadView { [super loadView]; UIButton *backButton = [[UIButton alloc] initWithFrame: CGRectMake(0, 0, 10.0f, 24.0f)]; UIImage *backImage = [UIImage imageNamed:@"left_arrow_icon"];

在我的详细视图控制器(导航控制器应用程序的一部分)中,我添加了自定义的“后退”按钮,如下所示:

- (void)loadView
{
    [super loadView];

    UIButton *backButton = [[UIButton alloc] initWithFrame: CGRectMake(0, 0, 10.0f, 24.0f)];

    UIImage *backImage = [UIImage imageNamed:@"left_arrow_icon"];
    [backButton setBackgroundImage:backImage  forState:UIControlStateNormal];

    [backButton setTitle:@"" forState:UIControlStateNormal];
    [backButton addTarget:self action:@selector(popBack) forControlEvents:UIControlEventTouchUpInside];

    UIBarButtonItem *backButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];

    self.navigationItem.leftBarButtonItem = backButtonItem;
}

-(void) popBack {
    [self.navigationController popViewControllerAnimated:YES];
}
正如你们所看到的,我添加了左栏按钮并分配了“弹出”操作。基本上,左箭头图标是银色的,但当我按下它时,iOS会将其更改为深灰色

我的问题是,我可以(以及如何)将初始颜色更改为白色吗?可能吗

编辑。我使用xcode5

编辑2: 那也不行

试试这段代码-

[backbutton setTitleTextAttributes: 
    [NSDictionary dictionaryWithObjectsAndKeys:[UIColor blackColor], UITextAttributeTextColor,
    [UIColor blackColor], UITextAttributeTextShadowColor, 
    [NSValue valueWithUIOffset:UIOffsetMake(0, -1)], UITextAttributeTextShadowOffset, 
    [UIFont fontWithName:HELVETICA_REGULAR_FONT size:17.0], UITextAttributeFont, nil] forState:UIControlStateNormal];

试试这个代码。这对我来说非常有效-

UIImageView *navigationBarImage = [[UIImageView alloc] initWithImage:[UIImage    imageNamed:@"Navigation.png"]];
navigationBarImage.frame = CGRectMake(0, 0, 320, 44);
navigationBarImage.userInteractionEnabled = YES;
navigationBarImage.backgroundColor = [UIColor colorWithRed:28.0/255.0 green:53.0/255.0 blue:102.0/255.0 alpha:1.0];
[self.view navigationBarImage];
[navigationBarImage release];

UIButton *backBarBtn1 = [UIButton buttonWithType:UIButtonTypeCustom];
backBarBtn1.frame = CGRectMake(13, 12, 20, 20);
[backBarBtn1 setImage:[UIImage imageNamed:@"ic_back3.png"] forState:UIControlStateNormal];
backBarBtn1.backgroundColor = [UIColor clearColor];
[backBarBtn1 addTarget:self action:@selector(backBtnAction:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:backBarBtn1];

此解决方案仅更改我通过故事板添加的图标。但我在代码中添加了这个图标,它不会改变。它是银色的。你为什么要声明它是银色的?你能粘贴你的loadView方法吗?实际上,我想在这里创建自定义导航栏,而该图像视图是用于导航栏图像的。我只需要在导航栏中添加一个按钮。我想在左上角有我自己的png图标。png文件中的箭头为银色。使用上面显示的代码,我可以看到我的箭头,“返回”的动作也可以…但是我希望这个图标是纯白色的。一定有办法,因为Xcode或“某物”会将此浅银色更改为深灰色(当按下按钮时):/您试对了吗??[…..NSDictionary Dictionary WithObjectsandKeys:[UIColor whiteColor],UITextAttributeTextColor,…]嗯,您编写了backbutton(在我的示例UIButton中)。UIButton没有setTitleTextAttributes方法。所以我猜,你指的是反布托主义。所以我就这么做了(在我的edit2上有问题的掠夺)。。但它不起作用