Creating a UIView that sticks to bottom of UITableView

前端 未结 7 648
一个人的身影
一个人的身影 2021-01-05 06:47

I have a grouped UITableView and I\'d like to add a UIButton to the very bottom of my UITableView. I\'m using Storyboard and a UITableViewControlle

相关标签:
7条回答
  • 2021-01-05 07:33

    Yes it's possible in UITableViewConroller. Inside the viewDidLoad() function in your UITableViewController class add the following code:

        let bottomView = UIView()
        bottomView.backgroundColor = .red // or your color
        bottomView.frame = CGRect(x: 0, y: UIScreen.main.bounds.size.height - 78, width: tableView.frame.size.width, height: 78) // 78 or your size of view
        navigationController?.view.addSubview(bottomView)
        tableView.tableFooterView = UIView()
    

    enter image description here

    0 讨论(0)
提交回复
热议问题