Search code examples
uitableviewios6uinavigationbar

Missing drop shadow under UINavigationBar in combination with UITableView


When I try to add a custom background to a navigation bar, their is no drop shadow on top of the table view. In the subviews everything is fine.

Here is my code I use.

// Create resizable images
UIImage *gradientImage44 = [[UIImage imageNamed:@"navbar"]
                            resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
    
// Set the background image for *all* UINavigationBars
[[UINavigationBar appearance] setBackgroundImage:gradientImage44
                                   forBarMetrics:UIBarMetricsDefault];
    // Customize NavBar Shadow
[[UINavigationBar appearance] setShadowImage:nil];

Not existing drop shadow

My navigation bar

Existing drop shadow

Sub Views

Update: Found this answer, but does not work. I have done it exactly in the same way :-(.


Solution

  • I fixed it, by reimplementing the the navigation controller. The view hierarchy looked like this.

    UIView 
    +- Navigation View
    +- Table View
    

    I changed my UIView to an table view and added this to the UINavigation Controller. That fixed the missing shadow issue.