UITableView titleForHeaderInSection shows all caps

前端 未结 14 930
孤独总比滥情好
孤独总比滥情好 2021-01-30 16:28

I am using titleForHeaderInSection to show a header for a UITableView section. It worked fine with the iOS6 SDK, but the iOS7 SDK shows the header in all CAPS.

I guess

14条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-30 17:02

    In addition to @Animal451's post. For swift 3 you can use

    func tableView(_ tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) {
      guard section == 0 ,
        let tableViewHeaderFooterView = view as? UITableViewHeaderFooterView
        else { return }
    
      tableViewHeaderFooterView.textLabel?.text = "Your awesome string"
     }
    

    And then ignore - titleForHeaderInSection:

    Keep in mind that this code is for 1st section only. If you want to go through all of your sections, you'll need to add support for them

提交回复
热议问题