【问题标题】:adding custom font for tableview cells为表格视图单元格添加自定义字体
【发布时间】:2018-10-11 16:37:47
【问题描述】:

我想为我的应用添加自定义字体,所以我在这里添加它,就像我为其他标签所做的那样。

let question = QuestionController.questionsList[questionIndex]
cell.nameLabel.text = question.answers?[indexPath.row]
cell.nameLabel.numberOfLines = 0
cell.nameLabel.lineBreakMode = .byWordWrapping
cell.nameLabel.font = UIFont(name: "USIS 1949", size, 25)

我无法让它适用于表格单元格中的标题/行。相反,我有这个错误:

无法使用类型为“(name: String, (UIContentContainer, CGSize) -> CGSize, Int)”的参数列表调用类型“UIFont”的初始化程序

有没有简单的解决方法?我是否在错误的部分中包含字体?

【问题讨论】:

  • 错字:size, 25 应该是size: 25

标签: ios swift uitableview fonts initializer


【解决方案1】:

试试这个:

let question = QuestionController.questionsList[questionIndex]
cell.nameLabel.text = question.answers?[indexPath.row]
cell.nameLabel.numberOfLines = 0
cell.nameLabel.lineBreakMode = .byWordWrapping
cell.nameLabel.font = UIFont(name: "USIS 1949", size: 25)

【讨论】:

    猜你喜欢
    • 2012-05-26
    • 1970-01-01
    • 1970-01-01
    • 2017-02-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多