[英]UITableViewcontroller Subclass need to apply Padding left and Right
我有一个 class 和 UITableViewcontroller 的子类,我在其中显示Tableview
我想用左右填充显示,任何人都可以说明如何在Tableview
上应用填充
我正在使用UITableview
https://github.com/amkomatz/EXTable的这个子类
好吧,你总是可以创建一个UIViewController
并手动添加一个UITableView
到它......这样你就可以精确地控制布局。
例如在常规UIViewController
子类的viewDidLoad()
内部:
let tableView = UITableView(/* use whichever init makes sense */)
tableView.delegate = self
tableView.dataSource = self
tableView.registerCellForReuse... // I forget the exact syntax off the top of my head
self.view.addSubview(tableView)
// set constraints (auto layout) as normal
但是,如果你真的想使用UITableViewController
你可以添加一些contentInset
(又名填充):
tableView.contentInset = UIEdgeInsets(top: 0, left: leftPadding, bottom: 0, right: rightPadding)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.