美文网首页
导航栏细线

导航栏细线

作者: lifeLL | 来源:发表于2018-02-08 16:19 被阅读0次
    
    UIImageView * _navBarHairlineImageView;
    
    _navBarHairlineImageView = [self findHairlineImageViewUnder:self.navigationController.navigationBar];
    
    -(void)viewWillAppear:(BOOL)animated
    {
        _navBarHairlineImageView.hidden = YES;
    }
    -(void)viewDidDisappear:(BOOL)animated
    {
        _navBarHairlineImageView.hidden = NO;
    }
    
    //通过一个方法来找到这个黑线(findHairlineImageViewUnder):
    - (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;
    }
    
    

    https://www.jianshu.com/p/effa4a48f1e3

    相关文章

      网友评论

          本文标题:导航栏细线

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