首页 > 解决方案 > 标题化 UITableViewHeader 标签

问题描述

我有一个分组的 UITableView,我在情节提要中布局,我想将每个部分的标题从大写更改为标题。

最干净的方法是什么?谢谢

标签: iosswift

解决方案


这会做到:

override func tableView(_ tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) {
    guard let header = view as? UITableViewHeaderFooterView else { return }
    header.textLabel?.text = header.textLabel?.text?.capitalized
}

推荐阅读