自定义字体不显示

时间:2015-03-26 07:32:50

标签: ios objective-c iphone

我想在我的应用程序中添加自定义字体。我正在添加我的项目。 然后添加.plist文件。

plist file

Resources

我的代码是

 UIFont *CiutadellaBold = [UIFont fontWithName:@"Light up the World with accented characters" size:90.0f];
    // Do any additional setup after loading the view, typically from a nib.
    [label setFont:CiutadellaBold];
    label.text =@"hello";

但是文字没有显示在我的自定义字体中。我做错了什么?

3 个答案:

答案 0 :(得分:2)

您的字体名称很可能与文件名不同。您可以在应用程序中找到可用的字体名称,如下所示:

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

答案 1 :(得分:1)

您的字体名称不等于文件名,您应该输入文件信息 enter image description here

答案 2 :(得分:0)

首先检查您的字体是否安装在Mac中的“Font Book”应用程序中。复制“postScript名称”并在代码中使用。

 UIFont *CiutadellaBold = [UIFont fontWithName:@"postScript name" size:90.0f];

请参阅随附的屏幕截图。enter image description here

注意:这适用于iPhoneSimulator。您还可以在设备中查看此内容。有时在设备中不会出现此问题。

相关问题