iOS--去除导航栏黑线

2020-01-06  本文已影响0人  请叫我大帅666

以前用的方法行不通了, 捣腾了一段时间,其他不多说, 看下面:

#pragma mark 去除黑线
- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    UIImageView *navBarHairlineImageView = [self findLineImageViewUnder:self.navigationBar];
    navBarHairlineImageView.hidden = YES;
}

- (UIImageView *)findLineImageViewUnder:(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 findLineImageViewUnder:subview];
        if (imageView) {
            return imageView;
        }
    }
    return nil;
}

感谢这位老哥: https://blog.csdn.net/qq_22080737/article/details/83826377, 一定要注意放的生命周期, 放在 viewDidAppear 里, 放 viewDidLoad 没生效

上一篇下一篇

猜你喜欢

热点阅读