Ios 使用UIView和UIView按钮添加UITableView背景视图

Ios 使用UIView和UIView按钮添加UITableView背景视图,ios,swift,uitableview,uiview,uibutton,Ios,Swift,Uitableview,Uiview,Uibutton,我正在尝试将我的UITableViewbackgroundView设置为UIView,并且在UIView中添加了一个UIButton,但是UIButton没有出现。我做错了什么 let view: UIView = UIView(frame: CGRect(x: 0, y: 0, width: self.menuTable.bounds.size.width, height: self.menuTable.bounds.size.height)) let loginButton: UIButt

我正在尝试将我的
UITableView
backgroundView设置为
UIView
,并且在
UIView
中添加了一个
UIButton
,但是
UIButton
没有出现。我做错了什么

let view: UIView = UIView(frame: CGRect(x: 0, y: 0, width: self.menuTable.bounds.size.width, height: self.menuTable.bounds.size.height))

let loginButton: UIButton = UIButton(frame: CGRect(x: 0, y: 0, width: 200, height: 200))
loginButton.setTitle("Login", for: .normal)
loginButton.backgroundColor = UIColor.white
loginButton.tintColor = UIColor.black
loginButton.addTarget(self, action:#selector(self.pressedConnection), for: .touchUpInside)
view.addSubview(loginButton)

self.menuTable.backgroundView = view
self.menuTable.separatorStyle = .none

为什么要向显示在表视图单元格后面的视图添加按钮?何时将该视图显示为背景视图?tableView当时是否有任何数据?