我创建了这个部分标题标题,不幸的是我不知道如何在右侧添加一些填充。
这是我的代码:
override func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let title: UILabel = UILabel()
title.text = "Days"
title.backgroundColor = UIColor.lightGrayColor()
title.textAlignment = NSTextAlignment.Right
return title
}
最佳答案
你可以这样做:
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let view = UIView(frame: CGRect(x: 0, y: 0, width: 20, height: 20))
let label = UILabel(frame: CGRect(x: 15, y: 5, width: tableView.frame.width, height: 20))
label.text = "Days"
label.textAlignment = .right
view.addSubview(label)
return view
}
关于ios - 向 UITableView 中的 Section Header 添加填充,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36390670/