iOS 设置导航条下方的黑线隐藏
{
// 导航条下方的黑Line 添加一个全局变量用来放找到的黑线
UIImageView * _navigationBarLine;
}
// 用这种方法可以保持bar的 translucent 属性 并且可以找到导航条中的黑线
-(UIImageView * )fineTheLineBelowNavigationBar:(UIView *)view
{
if ([view isKindOfClass:[UIImageView class]] && view.frame.size.height <=1.0) {
return (UIImageView *)view;
}
for (UIView * sub in view.subviews) {
UIImageView * image = [self fineTheLineBelowNavigationBar:sub];
if (image) {
return image;
}
}
return nil;
}
- (void)viewDidLoad {
[super viewDidLoad];
_navigationBarLine = [self fineTheLineBelowNavigationBar:self.navigationController.navigationBar];
}
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
_navigationBarLine.hidden = YES;
}
-(void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
_navigationBarLine.hidden = NO;
}