iOS Developer

iOS 导航栏去黑线

2016-10-27  本文已影响82人  cb6a1e2768d1
@interface ELItemController ()
{
   UIImageView *navBarHairlineImageView;
}
- (void)viewDidLoad {
    //设置导航去掉黑色横线
    UINavigationBar *navigationBar = self.navigationController.navigationBar;
    navBarHairlineImageView = [self findHairlineImageViewUnder:navigationBar];
}
#pragma mark - 导航横线

- (UIImageView *)findHairlineImageViewUnder:(UIView *)view {
    if ([view isKindOfClass:UIImageView.class] && view.bounds.size.height <= 1.0) {
        return (UIImageView *)view;
    }
    for (UIView *subview in view.subviews) {
        UIImageView *imageView = [self findHairlineImageViewUnder:subview];
        if (imageView) {
            return imageView;
        }
    }
    return nil;
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    navBarHairlineImageView.hidden = YES;
    
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
//    navBarHairlineImageView.hidden = NO;
}
上一篇下一篇

猜你喜欢

热点阅读