答案 0 :(得分:15)
您可以尝试
lbl.font = UIFont(name:"FontAwesome",size:15)
名称应该是安装时的字体名称。不是因为您的文件名是 Noto Kufi Arabic 而不是 NotoKufiArabicRegular
单击该字体并用“字体书”将其打开,然后安装该字体,然后准确指定上一行参数中显示的名称
答案 1 :(得分:4)
import Foundation
import UIKit
extension UIFont {
public enum OpenSansType: String {
case extraboldItalic = "-ExtraboldItalic"
case semiboldItalic = "-SemiboldItalic"
case semibold = "-Semibold"
case regular = ""
case lightItalic = "Light-Italic"
case light = "-Light"
case italic = "-Italic"
case extraBold = "-Extrabold"
case boldItalic = "-BoldItalic"
case bold = "-Bold"
}
static func OpenSans(_ type: OpenSansType = .regular, size: CGFloat = UIFont.systemFontSize) -> UIFont {
return UIFont(name: "OpenSans\(type.rawValue)", size: size)!
}
var isBold: Bool {
return fontDescriptor.symbolicTraits.contains(.traitBold)
}
var isItalic: Bool {
return fontDescriptor.symbolicTraits.contains(.traitItalic)
}
}
使用:
self.numberLabel.font = UIFont.OpenSans(.bold, size: 20)
答案 2 :(得分:0)
如果先前的答案无济于事,那么您肯定不能在xCode上正确配置所有链接!
您可以在此处获得更多信息: Medium.com