【发布时间】:2015-11-29 22:06:48
【问题描述】:
标签标题对齐是左对齐,但我希望居中。 我的约束有什么问题?
func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView?
{
var title: UILabel = UILabel()
title.text = sectionsArray[section]
title.textColor = UIColor(red: 77.0/255.0, green: 98.0/255.0, blue: 130.0/255.0, alpha: 1.0)
title.backgroundColor = UIColor(red: 225.0/255.0, green: 243.0/255.0, blue: 251.0/255.0, alpha: 1.0)
title.font = UIFont.boldSystemFontOfSize(10)
var constraint = NSLayoutConstraint.constraintsWithVisualFormat("H:[label]", options: NSLayoutFormatOptions.AlignAllCenterX, metrics: nil, views: ["label": title])
title.addConstraints(constraint)
return title
}
【问题讨论】:
标签: ios uitableview header alignment constraints