美文网首页
iOS 处理tableView下拉时顶部出现的空白

iOS 处理tableView下拉时顶部出现的空白

作者: 倒着游的鱼 | 来源:发表于2021-07-20 19:42 被阅读0次

方法一:判断offset设置tableView的背景颜色
(适用只有一个section的情况|适用顶部为纯颜色的情况)

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    
    if (scrollView.contentOffset.y < 0) {
        self.tableView.backgroundColor =  [UIColor colorWithRed:255/255.0 green:231/255.0 blue:217/255.0 alpha:1.0];//和顶部区域同色
        
    } else {
         self.tableView.backgroundColor = [UIColor colorWithRed:247/255.0 green:247/255.0 blue:247/255.0 alpha:1.0];//还原tableView背景色
        
    }
}

带MJ刷新方式二:

QMRefreshGifHeader *gifHeader = [QMRefreshGifHeader headerWithRefreshingBlock:^{
        //请求数据     
    }];
[gifHeader setJsonName:kgifHeaderJsonName];
 gifHeader.backgroundColor = [UIColor colorWithRed:255/255.0 green:231/255.0 blue:217/255.0 alpha:1.0];
  self.tableView.mj_header = gifHeader;
    
 UIView *maskView = [[UIView alloc]initWithFrame:self.tableView.frame];
 maskView.backgroundColor = [UIColor colorWithRed:255/255.0 green:231/255.0 blue:217/255.0 alpha:1.0];
 maskView.topY -= maskView.height;
 [self.tableView.mj_header addSubview:maskView];
 [self.tableView.mj_header sendSubviewToBack:maskView]; //调整到父视图的最下面

原作来源
https://www.jianshu.com/p/3c5304074598

相关文章

网友评论

      本文标题:iOS 处理tableView下拉时顶部出现的空白

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