我试图将我的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
发布于 2018-12-10 15:21:23
tableview的背景视图将不可见,因为如果要验证backgroundView是否存在,则单元格图层位于其上方
self.tableView.bounces = true
当你弹出时你会看到它,也从你的框架中考虑一个表头
https://stackoverflow.com/questions/-100005123
复制相似问题