Если вы встраиваете UIButton в UIView, то вы можете использовать UITableVIewController.
Вот урезанный код одного из моих экземпляров UITableViewController. Есть UITableView, и внизу страницы есть UIView с UIButton на нем:
class ViewController : UITableViewController
{
@IBOutlet private weak var floatingView: UIView!
override func viewDidLoad()
{
super.viewDidLoad()
self.initSaveView()
}
override func viewWillLayoutSubviews()
{
super.viewWillLayoutSubviews()
self.tableView.bringSubviewToFront(self.floatingView)
}
fileprivate func initSaveView()
{
self.tableView.contentInset = UIEdgeInsets(top: 0.0, left: 0.0, bottom: self.floatingView.frame.height, right: 0.0)
self.tableView.scrollIndicatorInsets = UIEdgeInsets(top: 0.0, left: 0.0, bottom: self.floatingView.frame.height, right: 0.0)
self.floatingView.frame.origin.y = self.tableView.bounds.origin.y + self.tableView.frame.height - floatingView.frame.height
self.floatingView.autoresizingMask = .flexibleTopMargin
self.view.addSubview(self.floatingView)
}
}
extension ViewController
{
override func scrollViewDidScroll(_ scrollView: UIScrollView)
{
floatingView.frame = CGRect(x: self.floatingView.frame.origin.x, y: self.tableView.bounds.origin.y + self.tableView.frame.height - floatingView.frame.height, width: self.floatingView.frame.size.width, height: self.floatingView.frame.size.height)
}
}
Надеюсь, это поможет вам начать. floatingView
был добавлен с помощью Interface Builder (просто перетащите UIView в верхнюю часть панели UITableViewController, затем добавьте свой выход).