I am working with a custom navigation bar.
In my AppDelegate I've done this.
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"navbar"] forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setTitleTextAttributes: @{
UITextAttributeTextColor: [UIColor whiteColor],
UITextAttributeTextShadowColor: [UIColor whiteColor],
UITextAttributeTextShadowOffset: [NSValue valueWithUIOffset:UIOffsetMake(0.0f, 1.0f)],
UITextAttributeFont: [UIFont fontWithName:@"Carrois Gothic" size:18.0f]
}];
On viewController level I put buttons inside the navigationController. In all viewControllers I have only one button inside the navigationbar.
But in one VC I need to set 2 buttons and I also change the backgroundImage of the navigationbar. So what I copied the same code as above in the ViewDidLoad but now with other image. This is working.
But now I want in all other VC's the first navigationbar. So in my viewDidDisappear I copied again the code with the other image again.
The following is going wrong:
Can anybody help me with this ?
PS: I am working with a tabbarcontroller. So if I say switching VC's I mean going to another tab in the tabbarcontroller
Do not use the appearance proxy in the ViewController. Just set the background directly:
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"navbar"] forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setTitleTextAttributes: @{
UITextAttributeTextColor: [UIColor whiteColor],
UITextAttributeTextShadowColor: [UIColor whiteColor],
UITextAttributeTextShadowOffset: [NSValue valueWithUIOffset:UIOffsetMake(0.0f, 1.0f)],
UITextAttributeFont: [UIFont fontWithName:@"Carrois Gothic" size:18.0f]
}];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With