找不到添加到xcode 7的自定义字体的名称 [英] can't find the name of custom font added to xcode 7
问题描述
我无法获取自定义字体的名称。我添加字体到我的项目与复制如果需要选项检查。我将字体名称添加到应用程序提供的info.plist标记字体中。我添加了字体到复制包资源。
字体出现在自定义选项卡下的情节提要中。但是,当我尝试用代码找到这个字体的名称,它不起作用。真的很奇怪,因为这通常起作用。这可能是什么原因?
字体的情节图板图像:
代码以编程方式查找名称:
viewDidLoad(){
$ p $
//在调试器中没有PTSans系列。
for family:UIFont.familyNames()中的字符串
{
print(\(family))
for name:UIFont.fontNamesForFamilyName(family)中的字符串
print(== \(names))
}
}
}
解决方案您是否尝试过类似以下内容:
[yourlabel setFont:[UIFont fontWithName:@PT Sanssize:20]];
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. I added the font to 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)") } } }
解决方案Did you try something like:
[yourlabel setFont:[UIFont fontWithName:@"PT Sans" size:20]];
这篇关于找不到添加到xcode 7的自定义字体的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!