现在我正在使用好的'tableView.tableFooterView = UIView()
,但这会让屏幕的底部变白。有没有办法让它在最后一个单元格下方变灰?就像你使用静态细胞而不是动态细胞一样,你的灰色底层是最后一个细胞。就像是可以设置未使用的细胞清除的东西?或者所有单元格最初都是清除的,只有在填入数据时才设置为白色?我发现的所有答案总是使用tableView.tableFooterView = UIView()
,这导致结果与我正在寻找的结果不同。
答案 0 :(得分:0)
您可以使用UView
和let footerView = UIView(frame: CGRect(x: 0, y: 0, width: width, height: height))
将footerView.backgroundColor = UIColor.ANYCOLORYOUWANT
的大小和颜色调整为任意大小的颜色。然后,在为UIView
设置颜色后,将其指定为tableFooterView
。 (宽度和高度是你想要的任何东西)。像这样:
let width: CGFloat = UIScreen.mainScreen().bounds.width
let height: CGFloat = 20
let footerView = UIView(frame: CGRect(x: 0, y: 0, width: width, height: height))
footerView.backgroundColor = UIColor.lightGrayColor()
tableView.tableFooterView = footerView
您可以使用viewDidLoad
(或子类)将上述代码放在视图控制器的UITableView
中。该代码在UITableView
的底部生成一个20px高,全宽,浅灰色视图。
如果您有任何疑问,请询问! :D
答案 1 :(得分:0)
没有未使用的单元格,您看到的是backgroundView
。
你可以尝试:
tableView.backgroundView.backgroundColor = UIColor.lightGrayColor()
我认为你也可以将backgroundView设置为自定义视图。