Ios 更改tableView?的颜色。tableFooterView

Ios 更改tableView?的颜色。tableFooterView,ios,uitableview,swift3,Ios,Uitableview,Swift3,我创建了一个如图所示的tableView。截面和单元之间有空间。因此,空间的颜色是tableview的默认颜色 为了删除tableview上的额外行,我在tableview?.tableFooterView中添加了UIVIew() let footerView = UIView() self.tableView?.tableFooterView = footerView 我想让UIView的颜色在图片的“目标颜色”中相同 我试过下面的方法,但不起作用 let footerView = UIVi

我创建了一个如图所示的tableView。截面和单元之间有空间。因此,空间的颜色是tableview的默认颜色

为了删除tableview上的额外行,我在
tableview?.tableFooterView
中添加了UIVIew()

let footerView = UIView()
self.tableView?.tableFooterView = footerView
我想让UIView的颜色在图片的“目标颜色”中相同

我试过下面的方法,但不起作用

let footerView = UIView()
footerView.backgroundColor = UIColor.black
footerView.tintColor = UIColor.black
self.tableView?.tableFooterView = footerView
我该怎么办?
谢谢

尝试为此设置
tableView
backgroundColor

self.tableView?.backgroundColor = UIColor.white //Or color that you want

如果要为tableview页脚使用不同的颜色,还有另一种解决方案

Swift 4

    tableView.tableFooterView = UIView()
    let screenRect = view.bounds;
    let screenWidth = screenRect.size.width;
    let screenHeight = screenRect.size.height;
    let footerHeight = screenHeight - ((YOUR_SECTION_HEIGHT * SECTION_COUNT) + (YOUR_ROW_HEIGHT * ROW_COUNT))
    let footerView = UIView(frame: CGRect(x: 0.0, y: 0.0, width: screenWidth, height: screenHeight - footerHeight))
    footerView.backgroundColor = UIColor.darkGray // or your custom color
    tableView.tableFooterView?.addSubview(footerView)
目标-C

    self.tableView.tableFooterView = [[UIView alloc] init];
    CGRect screenRect = self.view.bounds;
    CGFloat screenWidth = screenRect.size.width;
    CGFloat screenHeight = screenRect.size.height;
    CGFloat footerHeight = screenHeight - ((YOUR_SECTION_HEIGHT * SECTION_COUNT) + (YOUR_ROW_HEIGHT * ROW_COUNT));
    UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, screenWidth, screenHeight - footerHeight)];
    footerView.backgroundColor = [UIColor darkGrayColor]; // or your custom color
    [self.tableView.tableFooterView addSubview:footerView];

因为您没有设置页脚视图的高度,而且这不是一种方法,所以请在表的背景视图上设置所需的颜色,正如nirva D已经提到的那样