简体   繁体   English

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

[英]custom font not displaying on some simulator

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 app中的名称。

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.选择Targets-> Build Phases-> Copy Bundle Resoures->单击+按钮 - >添加自定义字体

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 将它们包含在您应用的plist中
  4. Make sure you're referring to the correct font name . 确保您指的是正确的字体名称

You can log all fonts by putting this on your app delegate's didFinishLaunchingWithOptions : 你可以通过将它放在你的app委托的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/

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

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. 当我通过选择“创建组”添加文件夹时,各个字体文件被添加到捆绑资源中,字体出现在模拟器中。

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中加载

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM