UITableView change header title color

后端 未结 6 625
隐瞒了意图╮
隐瞒了意图╮ 2021-02-13 10:18

I\'m styling the UITableView in InAppSettingsKit and want to change the color of the header title:

\"image

6条回答
  •  余生分开走
    2021-02-13 10:43

    It took me a few minutes to "translate" this to Swift, but here's a working equivalent in Swift 1.2 (iOS 8). Be sure and implement UITableViewDelegate in your class:

    // MARK: - VIEW METHODS
    override func viewDidLoad() {
        tableView.delegate = self
    }
    
    // MARK: - TABLEVIEW DELEGATE METHODS
    override func tableView(tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) {
        let header = view as! UITableViewHeaderFooterView
        header.textLabel.textColor = UIColor.whiteColor()
    }
    

提交回复
热议问题