2017-06-29 109 views
0

我在表格视图底部有一张白色空白区域的表格。但我希望这个区域是灰色的。我添加了一个灰色页脚,但它太小了。如何染UITableView底部空的空间?

我该怎么办?

What I want

+0

'我添加了一个灰色的页脚,但它太small.'你是怎么做到的? – Larme

+0

@Larme,我拖放UIView到UITableView –

回答

1

设置tableView'sbackgroundColorgray颜色和tableFooterViewUIView

self.tableView.tableFooterView = UIView() 
self.tableView.backgroundColor = .gray 
+0

我已经试过但没有成功。 –

+1

@AlexeySubbota删除灰色视图,您可以在界面生成器中拖放'tableView'并将这两行放入'viewDidLoad'中。 –

1

添加下面的线,

self.tableView.tableFooterView = UIView()

它将完美的作品。

+0

谢谢,它也可以,但我只能接受一个答案。 –

+0

好吧,先生。快乐编码... –

1

如果因为tableview中的页脚然后使用下面的委托方法否则,如果它的背景视图颜色修改你的tableview,以适应父视图的rect

func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? { 

     return UIView() 
    } 

    func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { 

     return 0 
    }