Not sure if this addition is what you were hoping for, but I'm using this:
/* input: The image and a tag to later identify the view */
@implementation UINavigationBar (UINavigationBarCategory)
-(void)setBackgroundImage:(UIImage*)image withTag:(NSInteger)bgTag{
if(image == NULL){ //might be called with NULL argument
return;
}
UIImageView *aTabBarBackground = [[UIImageView alloc]initWithImage:image];
aTabBarBackground.frame = CGRectMake(0,0,self.frame.size.width,self.frame.size.height);
aTabBarBackground.tag = bgTag;
[self addSubview:aTabBarBackground];
[self sendSubviewToBack:aTabBarBackground];
[aTabBarBackground release];
}
/* input: The tag you chose to identify the view */
-(void)resetBackground:(NSInteger)bgTag {
[self sendSubviewToBack:[self viewWithTag:bgTag]];
}
@end
You will probably do well with the resetBackground called in each viewcontroller's viewDidAppear like so:
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[[self.navigationController navigationBar] resetBackground:8765309];
}
The 8765309 is the tag number for this example, it can be anything you like.
It must be the same number you use when setting the background tag.
[[self.navigationController navigationBar] setBackgroundImage:myBackgroundImage withTag:8675309];