抱歉英语不好:-(
在这里我使用xcode 5和ios7,当在pushviewcontroller之后获取时,可以在后退按钮中改变颜色。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
ListViewController *viewList = [[ListViewController alloc] initWithNibName:@“ListViewController” bundle:nil];
[self.navigationController pushViewController: viewList animated:YES];
}
用户按下一个单元格,然后会出现ListViewController。在导航栏中,右侧栏按钮显示为粉红色。但后栏按钮没有变色。请看下面的屏幕截图。
我们可以在导航栏中更改颜色后退按钮吗?或者应该在后退按钮中添加图像?
答案 0 :(得分:8)
- (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];
}
试试吧......快乐的代码: - )
答案 1 :(得分:5)
要更改应用中的所有UIBarButtonItems
颜色,请在AppDelegate的应用程序窗口中设置tintColor
属性。比如,
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window.tintColor = [UIColor blueColor]; // or set color as you want.
return YES;
}
答案 2 :(得分:2)
您无法更改backBarButtonItem
的颜色,但可以更改其色调。尝试将以下内容添加到App Delegate:
[[UIBarButtonItem appearance] setTintColour:pinkColour]
小心,这会使你的酒吧按钮的全部粉红色。
答案 3 :(得分: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];