美文网首页
iOS兼容性bug

iOS兼容性bug

作者: 哥只是个菜鸟 | 来源:发表于2020-03-13 21:09 被阅读0次

1.导航栏下面的1px黑线bug

在base类中设置如下方法即可

-(void)hideNavigationBarBottomLine:(BOOL)hidden{
    //iOS10及以上的隐藏方法
    if ([UIDevice currentDevice].systemVersion.floatValue >= 10.0) {
        if ([self.navigationController.navigationBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)]) {
            NSArray *list=self.navigationController.navigationBar.subviews;
            for (id obj in list) {
                //10.0的系统字段不一样
                UIView *view =   (UIView*)obj;
                for (id obj2 in view.subviews) {
                    if ([obj2 isKindOfClass:[UIImageView class]]) {
                        UIImageView *image =  (UIImageView*)obj2;
                        if (image.frame.size.height <= 1) {
                            image.hidden = hidden;
                        }
                    }
                    
                    if ([obj2 isKindOfClass:[UIView class]]) {
                        UIView *view2 = (UIView *)obj2;
                        if (view2.frame.size.height <= 1) {
                            view2.hidden = hidden;
                        }
                    }
                }
            }
            
        }
        
        return;
    }
    //iOS10以下的隐藏方法
    if ([self.navigationController.navigationBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)]){
        NSArray *list = self.navigationController.navigationBar.subviews;
        for (id obj in list) {
            if ([obj isKindOfClass:[UIImageView class]]) {
                UIImageView *imageView = (UIImageView *)obj;
                NSArray *list2 = imageView.subviews;
                for (id obj2 in list2) {
                    if ([obj2 isKindOfClass:[UIImageView class]]) {
                        UIImageView *imageView2 = (UIImageView *)obj2;
                        if (imageView2.frame.size.height <= 1) {
                            imageView2.hidden = hidden;
                        }
                    }
                    if ([obj2 isKindOfClass:[UIView class]]) {
                        UIView *view2 = (UIView *)obj2;
                        if (view2.frame.size.height <= 1) {
                            view2.hidden = hidden;
                        }
                    }
                }
            }
        }
    }
}

2.iOS11以下tableview的header和footer重叠的bug

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
     if ([UIDevice currentDevice].systemVersion.floatValue < 11.0) {
         return 0.1f;
     }else{
         return 0;
     }
}

相关文章

网友评论

      本文标题:iOS兼容性bug

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