如何以编程方式选择系统字体?

时间:2016-08-27 17:41:52

标签: ios swift uifont

我想将“System semibold 13.0”(这是故事板中字体的名称)应用到tableview单元格组的标题上。为此,我正在使用:

    let header = view as! UITableViewHeaderFooterView
    header.textLabel?.font = UIFont(name: "Futura", size: 38)!
    header.textLabel?.textColor = UIColor.lightGrayColor()

但是idk要为名称字符串添加什么。我已经尝试输入“System Semibold”和“Semibold”,但两者都会导致一个未包装的可选崩溃。我需要在字符串中使用“System semibold 13.0”?

1 个答案:

答案 0 :(得分:3)

使用iOS 8.2及更高版本中提供的.systemFontOfSize。例如:

someLabel.font = UIFont.systemFontOfSize(38.0, weight: UIFontWeightSemibold)

UIFont Class Reference

相关问题