首页 > 代码库 > iOS隐藏导航栏底部灰线

iOS隐藏导航栏底部灰线

首先创建

<style>p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #de38a5 } span.s1 { } span.s2 { color: #ffffff }</style>

@interface TestVC()

<style>p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #ffffff } p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #ffffff; min-height: 21.0px } span.s1 { } span.s2 { color: #00b1ff }</style>

{

    UIImageView *navBarHairlineImageView;

}

- (void)viewWillAppear:(BOOL)animated

{

    [super viewWillAppear:animated];

    navBarHairlineImageView.hidden = YES;

}

- (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;

}在viewDidLoad中加入

<style>p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #08fa95 } span.s1 { } span.s2 { color: #ffffff } span.s3 { color: #de38a5 } span.s4 { color: #00b1ff }</style>

 

navBarHairlineImageView =[self findHairlineImageViewUnder:self.navigationController.navigationBar];

 

 

然后就完成了,可以运行看效果了

 

 

 

 

<style>p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #ffffff } span.s1 { }</style> <style>p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #ffffff } p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #08fa95 } p.p3 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #00b1ff } p.p4 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #de38a5 } span.s1 { } span.s2 { color: #de38a5 } span.s3 { color: #00b1ff } span.s4 { color: #ffffff } span.s5 { color: #8b87ff } span.s6 { color: #08fa95 }</style>

iOS隐藏导航栏底部灰线