导航栏中的返回按钮颜色没有改变。

5

非常抱歉我的英语不好 :-(
我正在使用Xcode 5和iOS 7,当从pushviewcontroller返回时无法更改返回按钮的颜色。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
        ListViewController *viewList = [[ListViewController alloc] initWithNibName:@“ListViewController” bundle:nil];
        [self.navigationController pushViewController: viewList animated:YES];
}

用户按下单元格,然后ListViewController将出现。在导航栏中,右侧的按钮会变成粉色。但是返回按钮没有改变颜色。请查看我附加的链接中的屏幕截图。
我们能否更改导航栏中返回按钮的颜色?或者应该在返回按钮中添加图片吗?

这个颜色是iOS7的默认颜色,你应该只用图片来替换它。 - Manimaran
4个回答

7
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
        ListViewController *viewList = [[ListViewController alloc] initWithNibName:@“ListViewController” bundle:nil];
        self.navigationController.navigationBar.tintColor=[UIColor readcolor]; //set color as you want…..
        [self.navigationController pushViewController: viewList animated:YES];
}

尝试一下...愉快编码 :-)

6

如果您希望更改应用程序中所有UIBarButtonItems的颜色,请在AppDelegate中设置应用程序窗口的tintColor属性。例如:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window.tintColor = [UIColor blueColor]; // or set color as you want.
    return YES;
}

也可以在Storyboard中设置这个。 - DogCoffee

2

您无法更改backBarButtonItem的颜色,但可以更改其色调。尝试将以下内容添加到您的应用程序委托:

[[UIBarButtonItem appearance] setTintColour:pinkColour]

请注意,这将使您所有的栏按钮都变成粉色。


0

尝试使用此代码来自定义返回按钮

UIView *backBtnView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 70, 40)];
backBtnView.backgroundColor = [UIColor clearColor];
UIButton *backBtn=[UIButton buttonWithType:UIButtonTypeCustom];
[backBtn setBackgroundColor:[UIColor clearColor]];
[backBtn setImage:[UIImage imageNamed:@"back.png"] forState:UIControlStateNormal];
[backBtn addTarget:self action:@selector(backBtnClicked) forControlEvents:UIControlEventTouchUpInside];
[backBtn setFrame:CGRectMake(5, 5, 57, 30)];
[backBtnView addSubview:backBtn];
self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc]initWithCustomView:backBtnView];

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接