美文网首页iOS Developer
iOS 导航栏去黑线

iOS 导航栏去黑线

作者: cb6a1e2768d1 | 来源:发表于2016-10-27 21:43 被阅读82次
    @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;
    }
    

    相关文章

      网友评论

        本文标题:iOS 导航栏去黑线

        本文链接:https://www.haomeiwen.com/subject/ytyquttx.html