添加自定义字体作为教程建议 here .
但无论是从 Stroyboard 还是从代码,我都无法设置 UILabel
的字体。我错过了什么?
请仔细阅读 article .
Step 5: Find the name of the font
This is a common pitfall for many people trying to include custom fonts into their iOS app. This was something that eluded me before as well and it’s the fact that when you specify which font you want to use, you’re not specifying the file name but rather, the font name. The tricky part is that the font name may not be what you expect. It could be very different than any of the visible font names that you can see.
So in order to easily find the name of the font that you want to use, you can output something to the console window and see for yourself.
您可以使用此代码为开发人员打印所有可用字体的名称:
在 UIFont.familyNames {
打印(“\(家庭)”)
对于 UIFont.fontNames(forFamilyName: family){
打印(“==\(名称)”)
}
}
它会产生这样的输出:
找到你的并将其用于:
label.font = UIFont(name: "SFProText-Heavy", size: 14.0)
要向界面生成器添加自定义字体,请从 Spotlight Search
中打开 Font Book
并将您的字体拖放到那里
关于ios - Xcode 中的自定义字体不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47614047/
欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://jike.in/) | Powered by Discuz! X3.4 |