How to remove UINavigationBar inner shadow in iOS 7?

前端 未结 6 511
深忆病人
深忆病人 2021-02-04 02:01

Inner shadow example

I\'m trying to put nav bar below the other one to make it look like one tall nav bar. But in iOS 7 UINavigationBar now has inner shadow on top and o

6条回答
  •  梦谈多话
    2021-02-04 02:09

    The "horizontal" line at the bottom of the navigation bar is simply it's shadowImage. It can simply be removed by applying an empty UIImage. According to the documentation you also have to set a custom background image:

    - (void)viewDidLoad
    {
        [super viewDidLoad];
    
        // Set the background and shadow image to get rid of the line.
        [self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
        self.navigationController.navigationBar.shadowImage = [[UIImage alloc] init];
    }
    

提交回复
热议问题