swift ios 8 change font title of section in a tableview

前端 未结 11 1603
夕颜
夕颜 2021-01-31 08:29

I would like to change the font type and font size of a section header in a table view controller.

My code:

func tableView(tableView: UITableView, willDi         


        
11条回答
  •  醉梦人生
    2021-01-31 08:58

     func tableView(tableView: UITableView,
            viewForHeaderInSection section: Int) -> UIView? {
                    let hView = UIView(frame: CGRectMake(0, 0, tableView.frame.width, 44))
                    hView.backgroundColor = UIColor.whiteColor()
                    let hLabel = UILabel(frame: CGRectMake(15, 2, 30, 44))
                    hLabel.font = UIFont(name: "YOUR_FONT_NAME", size: 30)
                    hLabel.textColor = kiExtremeOrange
                    hLabel.text = alphabets[section]
                    hView.addSubview(hLabel)
                    return hView
    }
    

    Note:First import the font you want to use

提交回复
热议问题