我有办法解决这个问题。如果您不想更改表格视图的背景颜色并且仍想删除此空间。
基本上在UIRefreshControl后面创建一个UIView *view,并在viewDidLoad方法中设置view的背景颜色为你想要的颜色
-(void)viewDidLoad
{
//you implementation of viewDidLoad
self.view = [[UIView alloc]initWithFrame:CGRectMake(0,0,self.view.frame.size.width,0)];
self.view.backgroundColor = [UIColor yourBackgroundColor];
[self.tableView insertSubview:self.view belowSubview:self.refreshControl];
}
然后实现一个UIScrollViewDelegate的方法,动态改变UIRefreshControl后面的view的高度来掩盖这个空隙。
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
CGFloat offset = scrollView.contentOffset.y;
[self.view setFrame:CGRectMake(0, 0, self.view.frame.size.width, offset + 20)]; // or any small number
}
请注意,您可能仍会看到一条线,因为它是 tableview 的分隔符,您可以更改 tableView 的分隔符颜色或样式以将其删除。