I'm trying to set a custom shadow image for the navigation bar in my table views, but it's only showing in some views. I've created a super class to set the styles for my table views.
- (void)viewDidLoad
{
[super viewDidLoad];
// Set navigation bar background
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"navigationbarbackground.png"] forBarMetrics:UIBarMetricsDefault];
// Set navigation bar shadow imag
[self.navigationController.navigationBar setShadowImage:[UIImage imageNamed:@"navigationbarshadow.png"]];
In the view I see at starting my app, no shadow is showed. But when I touch the [+] button in my navigation bar to open my 'add new item' table view, it does show a shadow.
Could someone point me in the right direction here?
you need to set custom
backgroudImage
for UINavigationBar, then theshadowImage
can work.Try this !
The Appearance proxy should work.
Just call it somewhere (e.g. in your AppDelegate) upon startup.
However if you create a storyboard with multiple UINavigationController's in it and a bunch of segue's pushing navigation controller's you might get a corrupt view controller structure which might be the problem here.
Another possible issue might be the
Clip Subviews
option of a Navigation Bar somewhere in your nib file or you storyboard. Make sure it is turned off if you want the shadow (image)!By the way, if you use imageNamed you don't need to include the file extension.