iOS 隐藏 Tabbar顶部细线

经过反复测试,是 一个类型为 _UIBarBackgroundShadowContentImageView
的视图造成的顶部细线
直接上代码
自定义 继承于UITabBar 的 视图, 重写layoutSubViews,隐藏 _UIBarBackgroundShadowContentImageView 类型的视图

@implementation MLTabbar

- (void)layoutSubviews
{
    [super layoutSubviews];
    NSMutableArray *array = [NSMutableArray array];
    [self.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        if ([obj isKindOfClass:NSClassFromString(@"_UIBarBackground")]) {
            [obj.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj2, NSUInteger idx, BOOL * _Nonnull stop) {
                //[array addObject:obj2];
                if ([obj2 isKindOfClass:[UIVisualEffectView class]]) {
                    [obj2.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj3, NSUInteger idx, BOOL * _Nonnull stop) {
                        if ([obj3 isKindOfClass:NSClassFromString(@"_UIBarBackgroundShadowContentImageView")]) {
                            obj3.hidden = YES;
                        }
                    }];
                }
            }];
        }
    }];
}

@end

猜你喜欢

转载自blog.csdn.net/LIUXIAOXIAOBO/article/details/131669674
今日推荐