![](/img/trans.png)
[英]Added custom font to project but when I try and use them I get a “fatal error: unexpectedly found nil while unwrapping an Optional value”
[英]Custom font is not added to project
我有與此處所述相同的問題
我有一種叫做ANTIQUAA.TTF的字體。 該字體已添加到項目的“支持文件”中。 在我的應用程序列表中,我輸入了應用程序提供的字體,並在其中添加了ANTIQUAA.TTF。
我無法在應用中使用此字體。 當我運行此方法時,看不到字體。
NSArray *familyNames = [[NSArray alloc] initWithArray:[UIFont familyNames]];
NSArray *fontNames;
NSInteger indFamily, indFont;
for (indFamily=0; indFamily<[familyNames count]; ++indFamily)
{
NSLog(@"Family name: %@", [familyNames objectAtIndex:indFamily]);
fontNames = [[NSArray alloc] initWithArray:
[UIFont fontNamesForFamilyName:
[familyNames objectAtIndex:indFamily]]];
for (indFont=0; indFont<[fontNames count]; ++indFont)
{
NSLog(@" Font name: %@", [fontNames objectAtIndex:indFont]);
}
[fontNames release];
}
[familyNames release];
我想念什么?
按下“副本捆綁資源”中的添加按鈕,然后單擊字體文件。
看起來您只需要將字體資源添加到.plist文件即可。
打開您的plist作為文本並粘貼:
<key>UIAppFonts</key>
<array>
<string>ANTIQUAA.TTF</string>
</array>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.