https://blog.csdn.net/qq_36557133/article/details/81604604
-(void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
//设置导航栏背景图片为一个无图的image,导航栏会加载空imgae,就自然透明掉了
[self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
//同理透明掉导航栏下划线
[self.navigationController.navigationBar setShadowImage:[[UIImage alloc] init]];
}
如果只是一个界面需要透明掉导航栏那么就要加上下面的代码了。
-
(void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];//导航栏的背景图和下划线都置空,就会回到默认的设置了
[self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];[self.navigationController.navigationBar setShadowImage:nil];
}