@property (nonatomic, weak) UIImageView *lineView;
-(void)viewWillAppear:(BOOL)animated{
_lineView.hidden = YES;
}
- (void)viewWillDisappear:(BOOL)animated{
_lineView.hidden = NO;
}
- (void)viewDidLoad {
[super viewDidLoad];
_lineView = [self getLineViewInNavigationBar:self.navigationController.navigationBar]; //获取导航栏下面黑线
}
//找到导航栏最下面黑线视图
- (UIImageView*)getLineViewInNavigationBar:(UIView*)view
{
if([view isKindOfClass:UIImageView.class] && view.bounds.size.height<=1.0) {
return(UIImageView*)view;
}
for(UIView*subviewinview.subviews) {
UIImageView*imageView = [self getLineViewInNavigationBar:subview];
if(imageView) {
return imageView;
}
}
return nil;
}
[self.navigationController.navigationBar setShadowImage:[UIImage new]];
[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];