在viewWillAppear方法中添加以下代碼
self.navigationController.navigationBar.translucent = YES;
[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:0];
self.navigationController.navigationBar.shadowImage=[UIImage new];//讓黑線消失的方法
在viewWillDisappear方法中添加以下代碼
[self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setShadowImage:nil];