[英]can't find the name of custom font added to xcode 7
I am having trouble with getting the name of my custom font. 我在获取自定义字体的名称时遇到问题。 I added font to my project with copy if needed option checked.
如果需要选中选项,我在我的项目中添加了字体。 I added the font name to the info.plist tag Fonts provided by an application.
我将字体名称添加到应用程序提供的info.plist标记字体中。 I added the font to Copy Bundle Resources.
我将字体添加到Copy Bundle Resources。
The font appears in storyboard under custom tab. 字体显示在自定义选项卡下的故事板中。 But when I try to find the name of this font with code, it doesn't work.
但是当我试图用代码找到这个字体的名称时,它不起作用。 Really strange because that normally works.
真奇怪,因为这通常有效。 What could be the reason for this?
这可能是什么原因?
Storyboard image of font: 故事板图片的字体:
Code to find the name programatically: 用于以编程方式查找名称的代码:
viewDidLoad(){
// there is no PTSans family in the debugger.
for family: String in UIFont.familyNames()
{
print("\(family)")
for names: String in UIFont.fontNamesForFamilyName(family)
{
print("== \(names)")
}
}
}
Btw, see the difference in example, the font name has a space, in actual there isn't. 顺便说一句,看到例子中的区别,字体名称有空格,实际上没有。
你尝试过这样的事情:
[yourlabel setFont:[UIFont fontWithName:@"PT Sans" size:20]];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.