简体   繁体   中英

Custom Font Visible in Storyboard but not Simulator

For some reason, the font that I have added to the Xcode Project is showing in the Storyboard but not in the Simulator .

Here is the Storyboard . 故事板图片

Here is the Simulator . 模拟器图片

As you can see, the two fonts are not the same. I have seen similar posts on Stack Overflow, but all of these posts suggest solutions that I already have tried or made sure are enabled. I have made sure that the project is the target, it is in copy bundled resources, and it has been added to the info.plist . Here are some more screenshots: <code>P List</code> 图片 目标会员形象 <code>复制捆绑资源</code> 图片

As this is a brand new project and I have only worked in storyboard mode, no code could be interfering with the text.

Thanks to @Ashley Mills, I was able to determine that the issue was I added the fonts in a folder and not independently. Adding the fonts separately fixed the issue.

Troubleshooting

You can do this adding custom font to your project following:

  • Add all font files to your project navigator.
  • Add font names(with the file extension) to info.plist . (or do it in code, comment to ask me how)
  • Check if the font name matches the font name, not it's file name!
  • Check if each font is added to target.
  • Use following code to print out all fonts in the app:

anywhere after app lunched

for familyName in UIFont.familyNames {
    for fontName in UIFont.fontNames(forFamilyName: familyName) {
        print(fontName)
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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