The return button does not receive a color change in the navigation bar

Sorry for the poor English :-(
Here I use xcode 5 and ios7, Can dnt change the color in the back button when you get after pushviewcontroller.

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

The user clicks on a cell, then a ListViewController will appear. The navigation bar on the right displays a pink color. but didn’t get the color change in the bar button. Please see the screenshot, I added the link below.

enter image description here

Can I change the back button on the navigation bar ?. Or do you need to add an image to the back button?

+4
source share
4 answers
- (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 ... Lucky code :-)

+8

UIBarButtonItems tintColor AppDelegate.

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

You cannot change the color backBarButtonItem, but you can change its hue. Try adding the following to your application delegate: [[UIBarButtonItem appearance] setTintColour:pinkColour]

Be careful, this will result in ALL of your buttons on the panel.

+2
source

Try this to customize the 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];
0
source

Source: https://habr.com/ru/post/1525901/


All Articles