NavigationBar底部有条横线怎么办

@property (nonatomic,strong)UIImageView *imageView;


- (void)viewDidLoad {

    UINavigationBar *navigationBar =self.navigationController.navigationBar;

_imageView = [self findHairlineImageViewUnder:navigationBar];

}


- (UIImageView *)findHairlineImageViewUnder:(UIView *)view {

    if ([view isKindOfClass:UIImageView.class] && view.bounds.size.height <= 1.0) {

        return (UIImageView *)view;

    }

    for (UIView *subviewin view.subviews) {

        UIImageView *imageView = [selffindHairlineImageViewUnder:subview];

        if (imageView) {

            return imageView;

        }

    }

    return nil;

}


- (void)viewWillAppear:(BOOL)animated {

    [super viewWillAppear:animated];

    self.imageView = YES;

}

- (void)viewWillDisappear:(BOOL)animated {

        [super viewWillDisappear:animated];

        navBarHairlineImageView.hidden = NO;

}



另外一种方法,在横线位置添加一张透明图片 在viewdidload中调用就可以

- (void)cancleLineOnNavigationBar

{

    UINavigationBar *navigationBar =self.navigationController.navigationBar;

    [navigationBar setBackgroundImage:[UIImageimageNamed:@"cgClear"]

                       forBarPosition:UIBarPositionAny

                           barMetrics:UIBarMetricsDefault];

    [navigationBar setShadowImage:[UIImagenew]];

}



附近把我用的图片传上了,懒的修,宽了点,自行调整吧

你可能感兴趣的:(navigation下的横线,去掉导航栏分割线)