Reputation: 1740
I use UIView() for remove separate line and it works but changing background color of footer view doesn't work. This is my code. Can somebody explain why? Thank you so much!
let footerView = UIView()
footerView.backgroundColor = UIColor(hexString: "#F7F9FC")
myTableView.tableFooterView = footerView
Upvotes: 1
Views: 153
Reputation: 171
I think you must set a frame for footer view. If you just only create UIView then the default of Apple will create UIView with frame is zero. You need to set width, height, x, y for it to display in TableView
let frame = CGRect(x: 0, y: 0, width: yourWidthExpect, height: yourHeightExpect))
let footerView = UIView(frame: frame)
After that you can set background color and do anything.
Upvotes: 1
Reputation: 434
It is because the size of your footerView is zero.
let footerView = UIView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 40.0))
footerView.backgroundColor = UIColor(hexString: "#F7F9FC")
myTableView.tableFooterView = footerView
Upvotes: 5