我已经UITableViewController
了,我在界面构建器的tableview下面放了一个UILabel
。但是,我似乎无法控制标签的实际Y位置。桌面视图和标签之间存在很大差距,我希望通过稍微移动标签来减少这种差距。我尝试以编程方式移动标签origin.y
,但它仍保留在同一位置。
有没有办法做到这一点?
答案 0 :(得分:0)
如果您希望它位于表格视图的底部,您只需将其添加为tableFooterView
即可。例如:
override func viewDidLoad() {
super.viewDidLoad()
let footerLabel = UILabel()
footerLabel.text = "Some Text"
footerLabel.textAlignment = .Center
footerLabel.textColor = UIColor.redColor()
footerLabel.sizeToFit()
self.tableView.tableFooterView = footerLabel
}
您可以使用添加到UIViewController
或UITableViewController
的表格视图。
tableFooterView
直接邻接表格视图的最后一部分的页脚。
override func tableView(tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 0.1 // adjust this value to determine how close the label is to the last table view cell. Don't return 0 unless you want the default value for grouped style table views
}