使用带UIVutton的UIView添加UITableView backgroundView

时间:2018-06-09 01:08:54

标签: ios swift uitableview uiview uibutton

我正在尝试将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

0 个答案:

没有答案