私はいくつかの問題があります。私はカスタムテーブルヘッダーセクションを作成します。ここに私のコードです:親ビューでテキストラベルの高さを管理する方法
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let sectionHeader = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.size.width, height: 36))
sectionHeader.backgroundColor = #colorLiteral(red: 0.1215686277, green: 0.01176470611, blue: 0.4235294163, alpha: 1)
tableView.backgroundColor = colors.background
let headerName = UILabel(frame: CGRect(x: 15, y: 0, width: tableView.frame.size.width, height: sectionHeader.frame.size.height))
headerName.font = UIFont(name: "Helvetica", size: 12)
headerName.text = sectionHeaders[section]
headerName.backgroundColor = #colorLiteral(red: 0.9529411793, green: 0.6862745285, blue: 0.1333333403, alpha: 1)
headerName.clipsToBounds = true
sectionHeader.addSubview(headerName)
return sectionHeader
}
そして、ここでの結果である:私はマークされ、気づいた青と黄色、headerviewと同じではない、そのラベルの高さを持つ
。いくつかのいずれかのビューの高さをヘッダにtextlabel高さを管理する方法、およびテキストにheaderviewと同じではありませんverticaly
あなたは '使用のfuncのtableViewしたテキストを整列させる(_のtableView:のUITableView、heightForHeaderInSectionセクション:INT)'? –