I have created a very simple test case to reproduce this issue.
I am trying to set a footer view programmatically to a tableview. Please note that I am referring to the
I have tried the same with explicit frame values in swift and I achieved the behaviour as you asked for, Try it with the explicit frame value if you think its fine. And remove the layout constraints if its not needed.
@IBOutlet weak var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
tableView.delegate = self
tableView.dataSource = self
let footerView = UIView(frame: CGRect.init(x: 0, y: 0, width: tableView.frame.width, height: 50))
footerView.backgroundColor = UIColor.green
tableView.tableFooterView = footerView
}
extension ViewController: UITableViewDelegate, UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 10
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell")
cell?.textLabel?.text = "\(indexPath.row)"
return cell!
}
}