IOS 5 How to change the color of back button in a navigation bar?

后端 未结 5 1388
感动是毒
感动是毒 2020-12-28 09:09

I want to change the color of back button of a navigation bar to make it look like this\"enter

5条回答
  •  無奈伤痛
    2020-12-28 09:14

    The first line of jacob's answer didn't work for me because the backBarButtonItem was NULL. It is NULL because it's been created later automatically when switching to an other ViewController. At that time you can set the title of the button with

    self.title = @"nice title"; // self is here the view(controller) within the popoverController
    

    but you can't set the tintColor.

    What worked for me, was to create a new UIBarButtonItem without any style. Then set the title and color propertys and set it as backBarButtonItem.

    UIBarButtonItem *backButton = [[UIBarButtonItem alloc] init];
    backButton.title = @"go back - now!";
    backButton.tintColor = [UIColor colorWithRed:0.1 green:0.5 blue:0.7 alpha:1.0];
    self.navigationItem.backBarButtonItem = backButton;
    [okButton release];
    

提交回复
热议问题