OGeek|极客世界-中国程序员成长平台

标题: iphone - 无法摆脱 UITableView 的 tableFooterView 中的颜色 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 13:45
标题: iphone - 无法摆脱 UITableView 的 tableFooterView 中的颜色

我有一个包含三个部分的标准 UITableView。在表格的底部,我尝试添加一个 tableFooterView。似乎表格中的最后一行和 tableFooterView 的顶部之间有一个标准间距,这很好,但我的问题是这个间距中有不同的颜色,我不能不要摆脱。我需要那个间距来匹配我的 tableView 的背景。

这里有一些代码:

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;

这是一个屏幕截图(对于红色感到抱歉,但这是查看颜色差异的最简单方法)。

enter image description here



Best Answer-推荐答案


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

关于iphone - 无法摆脱 UITableView 的 tableFooterView 中的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18365044/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4