方法一:判断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]; //调整到父视图的最下面
网友评论