简体   繁体   English

后退按钮不会在导航栏中获得更改颜色

[英]back button don't get change color in navigation bar

Sorry for bad english:-( 抱歉英文不好:-(
Here i am using xcode 5 and ios7, Can dnt change color in back button when get after pushviewcontroller. 在这里我使用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];
}

User presses a cell then ListViewController will appear. 用户按下一个单元格,然后会出现ListViewController。 In Navigation bar, Right bar button appeared pink color. 在导航栏中,右侧栏按钮显示为粉红色。 but did not get change color in back bar button. 但后栏按钮没有变色。 Please see screen shoot i have attached link below. 请看下面我附上链接的屏幕截图。

在此输入图像描述

Can we change color back button in navigation bar?. 我们可以在导航栏中更改颜色后退按钮吗? Or Should add image in back button? 或者应该在后退按钮中添加图像?

- (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];
}

Try it... Happy code :-) 试试吧......快乐的代码:-)

For change all UIBarButtonItems color in your app, set the tintColor property on the application's window in the AppDelegate. 要在应用程序中更改所有UIBarButtonItems颜色,请在AppDelegate中的应用程序窗口上设置tintColor属性。 such like, 这样的,

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

You cannot change a backBarButtonItem 's colour but you can change its tint. 您无法更改backBarButtonItem的颜色,但可以更改其色调。 Try adding the following to your App Delegate: [[UIBarButtonItem appearance] setTintColour:pinkColour] 尝试将以下内容添加到App Delegate: [[UIBarButtonItem appearance] setTintColour:pinkColour]

Be careful, this will tint ALL of your bar buttons pink. 小心,这会使你的所有条形按钮变成粉红色。

Try this for customized back button 试试这个定制的后退按钮

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];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM