@interface ViewController ()
{
UIView *_navBackView;
}
@end
-(void)getBackView:(UIView*)superView
{
if ([superView isKindOfClass:NSClassFromString(@"_UINavigationBarBackground")])
{
//移除分割线
for (UIView *view in superView.subviews)
{
if ([view isKindOfClass:[UIImageView class]])
{
[view removeFromSuperview];
}
}
_navBackView = superView;
_navBackView.backgroundColor = [UIColor yellowColor];
_navBackView.alpha = 0;
}
else if ([superView isKindOfClass:NSClassFromString(@"_UIBackdropView")])
{
//_UIBackdropEffectView是_UIBackdropView的子视图,这是只需隐藏父视图即可
superView.hidden = YES;
}
for (UIView *view in superView.subviews)
{
[self getBackView:view];
}
}
3.在页面即将出现时调用此方法,传入参数为self.navigationController.navigationBar
-(void)viewDidAppear:(BOOL)animated
{
[self getBackView:self.navigationController.navigationBar];
}