如何删除UITableViews中的部分周围的“span”空间?

时间:2012-01-12 22:27:27

标签: ios uitableview

我正在尝试将背景图像(使用模式)添加到分组的TableView。问题是每个TableViewCell(以及它的页眉和页脚)都被一个空间包围,该空间采用与我设置为TableView的背景图像相同的背景图像,并且每个单元格从顶部使用图像。这是显而易见的,因为图像具有水平条带,并且在滚动时非常烦人,因为在这些空间之间,您可以在后面看到TableView的实际背景(即相同),从而产生奇怪的效果。

这里我附上了一个截图,但是在滚动时并不那么清楚。

enter image description here

我尝试将Cell背景设置为ClearColor,但它不起作用。

1 个答案:

答案 0 :(得分:0)

您还需要设置清晰的背景视图。例如,将以下内容放入自定义单元格的初始化程序中应该可以解决问题:

    [self setBackgroundColor:[UIColor clearColor]];
    UIView *blankBackgroundView = [[UIView alloc] initWithFrame:CGRectZero];
    [blankBackgroundView setBackgroundColor:[UIColor clearColor]];
    [self setBackgroundView:blankBackgroundView];
    [self setSelectedBackgroundView:blankBackgroundView];
    [blankBackgroundView release];
相关问题