I set up the title bar of the navigation controller with a background image, but I'm really trying to change the background color of the button back to transparent so that it matches the green title bar below it. I am new to iOS development. Can anyone suggest what can be done?
Here is the code I used to change the title bar of the navigation controller, just in case:
- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. if ([self.navigationController.navigationBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)] ) { UIImage *image = [UIImage imageNamed:@"greenbar.png"]; [self.navigationController.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault]; // [[UIBarButtonItem appearance] setBackButtonBackgroundImage:image forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; } //change back button image }
EDIT : after a little research, I managed to get what I wanted. Here is the code to change the background image for the back button:
UIImage *image1 = [UIImage imageNamed:@"back-bt.png"]; [[UIBarButtonItem appearance] setBackButtonBackgroundImage:image1 forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
The code above adds an image to all the buttons back in the navigation controller.
source share