xcode 自定义字体未显示在某些模拟器上

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26054237/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 05:42:02  来源:igfitidea点击:

custom font not displaying on some simulator

iosobjective-ciphonexcode

提问by Parth Pandya

I have tried deleted font from the xcode project and and copied again by dragging, but still custom font named "Helvetica-Neue-LT-Com-75-Bold-Outline.ttf" is not working on iphone 4 and 5c simulator but working in 5s simulator.

我已经尝试从 xcode 项目中删除字体并通过拖动再次复制,但名为“Helvetica-Neue-LT-Com-75-Bold-Outline.ttf”的自定义字体仍然无法在 iphone 4 和 5c 模拟器上运行,但可以在5s模拟器

To set the font name to UILabel, I am using the name from fontbook app.

要将字体名称设置为 UILabel,我使用的是 fontbook 应用程序中的名称。

采纳答案by l0gg3r

  1. Delete application from simulator
  2. Clean (by hitting "CMD + K" in Xcode)
  3. Run again
  1. 从模拟器中删除应用程序
  2. 清洁(通过在 Xcode 中点击“CMD + K”)
  3. 再次运行

回答by Preetha

Follow this steps,it's work fine

按照这个步骤,它工作正常

1.Select the project

1.选择项目

2.Select Targets->Build Phases->Copy Bundle Resoures->Click + Button->Add your Custom font

2.选择目标->构建阶段->复制捆绑资源->单击+按钮->添加自定义字体

回答by aj_f

Few things after including the font files in your project:

在您的项目中包含字体文件后的一些事情:

  1. Include them in the target
  2. Include them as bundle resources
  3. Include them on your app's plist
  4. Make sure you're referring to the correct font name.
  1. 将它们包含在目标中
  2. 将它们作为捆绑资源包含在内
  3. 将它们包含在您应用的 plist 中
  4. 确保您指的是正确的字体名称

You can log all fonts by putting this on your app delegate's didFinishLaunchingWithOptions:

您可以通过将其放在应用程序委托的didFinishLaunchingWithOptions 上来记录所有字体:

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

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

Details here: http://codewithchris.com/common-mistakes-with-adding-custom-fonts-to-your-ios-app/

详情请见:http: //codewithchris.com/common-mistakes-with-adding-custom-fonts-to-your-ios-app/

回答by SnoopyProtocol

My problem was that I had a fonts folder which contained my font files, and I added the file by selecting "Create folder references" instead of "Create groups".

我的问题是我有一个包含我的字体文件的字体文件夹,我通过选择“创建文件夹引用”而不是“创建组”来添加文件。

When I did this, my fonts folder was blue (instead of yellow), and only the font folder appeared in bundle resources; the individual font files contained in the folder did not.

当我这样做时,我的字体文件夹是蓝色的(而不是黄色),并且只有字体文件夹出现在捆绑资源中;文件夹中包含的单个字体文件没有。

When I added the folder by selecting "Create groups" the individual font files were added to bundle resources and the fonts appeared in the simulator.

当我通过选择“创建组”添加文件夹时,单个字体文件被添加到捆绑资源中,字体出现在模拟器中。

回答by Lahiru Pinto

Make sure you're not loading this custom font in the Launch Screen of the App. You can use images instead.

确保您没有在应用程序的启动屏幕中加载此自定义字体。您可以改用图像。

Custom fonts are not Loading in the LaunchScreen.storyboard

LaunchScreen.storyboard 中未加载自定义字体