Unable to remove shadow from navigation bar


I am trying to remove shadow from the navigationbar but not get success (iOS7).

Used the code below,

Method 1

    [self.navigationController.navigationBar setBackgroundImage:image

    [self.navigationController.navigationBar setShadowImage:[UIImage new]];

Method 2

    for (UIView *view in self.navigationController.navigationBar.subviews) {
        for (UIView *view2 in view.subviews) {
            if ([view2 isKindOfClass:[UIImageView class]]) {
                [view2 removeFromSuperview];

Method 3

    [self.layer setMasksToBounds:YES];

Method 4

    [[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
    [[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];

Method 5

    [self.navigationController.navigationBar setBackgroundImage:image

    [self.navigationController.navigationBar setShadowImage:[[UIImage imageNamed:@"transparentpx.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(1, 1, 1, 1)]];

None of them worked for me. Could any one suggest new method..

Using an empty image hasn't worked for me.

I had to use a 1x1 pixel transparent image as the shadow image in order for it to appear invisible.

[self.navigationBar setShadowImage:[[UIImage imageNamed:@"navbar-shadow"] resizableImageWithCapInsets:UIEdgeInsetsMake(1, 1, 1, 1)]];