2

I have a standard UITableView with three sections. At the bottom of the table I'm trying to add a tableFooterView. It seems as though there's a standard spacing between the last row in the table and the top of the tableFooterView, which is fine, but my problem is that there is a different color in this spacing that I can't get rid of. I need that spacing to match the background of my tableView.

Here's some code:

self.menuTable.backgroundColor = [UIColor redColor];
self.menuTable.backgroundView = nil;
self.menuTable.separatorColor = [UIColor clearColor];
self.menuTable.delegate = self;
self.menuTable.sectionHeaderHeight = 10.0;

UIView *footer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 200)];
footer.backgroundColor = self.menuTable.backgroundColor;
UILabel *footerLabel = [[UILabel alloc] initWithFrame:CGRectMake(60, 0, 205, 100)];
footerLabel.text = @"foo bar.";
footerLabel.textColor = [UIColor blackColor];
footerLabel.backgroundColor = self.menuTable.backgroundColor;
footerLabel.numberOfLines = 10;
footerLabel.font = [UIFont italicSystemFontOfSize:11.0];
[footerLabel sizeToFit];

[footer addSubview:footerLabel];
self.menuTable.tableFooterView = footer;

Here's a screenshot (sorry about the red, but it's the easiest way to see the differences in colors).

enter image description here

4

2 回答 2

1

哎呀。早些时候我试图添加一个 sectionFooterView,并已实现tableView:heightForFooterInSection:,最后一个部分返回 20。这就是那个间隙的来源,它的默认颜色是白色。由于我现在将文本放置为tableFooterView,因此我刚刚删除了该委托回调,并且一切都按预期呈现。

于 2013-08-21T19:14:55.187 回答
0

尝试这个

self.menuTable.backgroundColor = [UIColor clearColor];
self.view.backgroundColor = [UIColor redColor];
于 2013-08-21T18:37:24.887 回答