iOS~隐藏导航栏底部黑线(已适配iOS 13)

话不多说,直接上代码

- (void)viewWillAppear:(BOOL)animated {
    
    [super viewWillAppear:animated];
    
    [self.navigationController.navigationBar.subviews enumerateObjectsUsingBlock:^(UIView *view, NSUInteger idx, BOOL *stop) {
        
        if (@available(iOS 10.0, *)) {

            if (@available(iOS 13.0, *)) {
                
                self.navigationController.navigationBar.subviews[0].subviews[0].hidden = YES;
            }else {
                
                self.navigationController.navigationBar.subviews[0].subviews[1].hidden = YES;
            }
        }else{
            //iOS10之前使用的是_UINavigationBarBackground
            if ([view isKindOfClass:NSClassFromString(@"_UINavigationBarBackground")]) {
                
                [view.subviews firstObject].hidden = YES;
            }
        }
    }];
}

你可能感兴趣的:(iOS~隐藏导航栏底部黑线(已适配iOS 13))