Changing Font Size For UITableView Section Headers

前端 未结 11 776
借酒劲吻你
借酒劲吻你 2020-12-12 09:28

Can someone please instruct me on the easiest way to change the font size for the text in a UITableView section header?

I have the section titles implemented using t

11条回答
  •  眼角桃花
    2020-12-12 10:09

    Swift 4 version of Leo Natan answer is

    UILabel.appearance(whenContainedInInstancesOf: [UITableViewHeaderFooterView.self]).font = UIFont.boldSystemFont(ofSize: 28)
    

    If you wanted to set a custom font you could use

    if let font = UIFont(name: "font-name", size: 12) {
        UILabel.appearance(whenContainedInInstancesOf: [UITableViewHeaderFooterView.self]).font = font
    }
    

提交回复
热议问题