Xcode 自定义字体未显示在应用程序中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32039887/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Xcode custom font not showing in app
提问by Blip
I have downloaded Open Sans font and added all the .tff
files into my Xcode project, and have checked the checkbox in "Target Membership" pane for each file. I have added the UIAppFonts
key and values in Info.plist, and I am sure that the values are typo-free. Plus, the .tff
files are added to "Copy Bundle Resources", and the custom font is showing up in Interface Builder. And then I changed the font of all the labels to Open Sans in the Interface Builder (no code).
我已经下载了 Open Sans 字体并将所有.tff
文件添加到我的 Xcode 项目中,并选中了每个文件的“目标成员资格”窗格中的复选框。我已经UIAppFonts
在 Info.plist 中添加了键和值,并且我确信这些值没有拼写错误。另外,这些.tff
文件被添加到“Copy Bundle Resources”中,并且自定义字体显示在 Interface Builder 中。然后我在 Interface Builder 中将所有标签的字体更改为 Open Sans(无代码)。
But when I run the app in the simulator, all the labels and buttons are showing the system font in ultra small sizes, like this:
但是当我在模拟器中运行该应用程序时,所有标签和按钮都以超小尺寸显示系统字体,如下所示:
One thing to note is that I am using Xcode 7 beta 5, and the app's Base SDK is iOS 9.
需要注意的一件事是,我使用的是 Xcode 7 beta 5,并且该应用程序的 Base SDK 是 iOS 9。
But why is there this problem? Is it a bug? Thanks!
但是为什么会出现这个问题呢?这是一个错误吗?谢谢!
回答by Manuel BM
回答by Larry B
Blip, here's a photo of what I did in an empty "Single View" project. And, I could see the font on sim and IB editor. Anything look different for your project? Maybe recreate the basics in a new project, just to double check? All of my notes on the image were associated with my original thoughts...just use them for reference as you double check things.
Blip,这是我在一个空的“单一视图”项目中所做的照片。而且,我可以在 sim 和 IB 编辑器上看到字体。您的项目有什么不同吗?也许在新项目中重新创建基础知识,只是为了仔细检查?我在图像上的所有笔记都与我的原始想法相关……请在仔细检查时将它们用作参考。
回答by Martin
I recently encountered this problem too. But it only happened for one font-style of a font-family, the others worked fine. I could only solve it by using this font in a button, then the font was also available for other controls such as labels or the large title.
我最近也遇到了这个问题。但它只发生在一个字体系列的一种字体样式上,其他的工作正常。我只能通过在按钮中使用这种字体来解决它,然后该字体也可用于其他控件,例如标签或大标题。