前言
项目中可能用不同的字体,如果又支持国际化,不同语言设置不同字体。
获取字体名字:
func showAllFonts(){
let familyNames = UIFont.familyNames
var index:Int = 0
for familyName in familyNames {
let fontNames = UIFont.fontNames(forFamilyName: familyName as String)
for fontName in fontNames
{
index += 1
print("第 \(index) 个字体,字体font名称:\(fontName)")
}
}
}
在项目中在iOS13.0以前这样用是没问题的:
"AKbalthomNagaFont" = "AKbalthom Naga";
"AKbalthomNagaFontBold" = "AKbalthom Naga Bold";
但是iOS13.0以后就会获取不到字体而出现闪退
正确用法:
"AKbalthomNagaFont" = "AKbalthomNaga";
"AKbalthomNagaFontBold" = "AKbalthomNaga-Bold";
END.