自定义字体在iOS 5中不起作用

我在我的资源中添加了Avenir-Next-LT-Pro-Demi-Condensed_5186.ttf字体。 同样添加到我的info.plist中的应用程序提供的字体。 在我的代码中,我设置了这样的字体,

 titleLabel.font = [UIFont fontWithName:@"Avenir-Next-LT-Pro-Demi-Condensed_5186" size:10]; 

但这不适用于ios 5模拟器和设备。

尝试这个 ,

 The font name is not the font file name Avenir-Next-LT-Pro-Demi-Condensed_5186.ttf is a file name. simply double click the Avenir-Next-LT-Pro-Demi-Condensed_5186.ttf file it will automatically open the font reader.Get the font name from top of the font reader navigation bar.. 

在此处输入图像描述

 titleLabel.font = [UIFont fontWithName:@"Avenir Next LT Pro" size:10]; 

你必须检查它有时与字体文件名不同的字体名称…

http://codefriends.blogspot.in/2012/04/adding-custom-font-in-xcode.html

在Xcode 4.1中添加自定义字体得到了答案

请按照以下步骤操作

1.确保复制font ,选中"add to target"复选框。

2.首先在Finder中选择你的font显示并双击,确保你的font name必须与image相同

在此处输入图像描述

这里的字体名称是“eurofurence light”

3.将字体添加到.plist文件中

做完所有事情后检查你的字体—

  NSLog(@"%@",[UIFont fontNamesForFamilyName:@"Your font"]); 

根据font family使用BoldItalic ……

希望这对你有所帮助

我只是想补充一点,这并不是所有的时间都遵循这条规则。 最好的方法是在应用程序中注册字体并执行快速检查并validation字体名称。

Objective-C的

  for (NSString *familyName in [UIFont familyNames]) { for (NSString *fontName in [UIFont fontNamesForFamilyName:familyName]) { NSLog(@"%@", fontName); } } 

迅速

  for familyName in UIFont.familyNames() { for fontName in UIFont.fontNamesForFamilyName(familyName){ print(fontName) } }