Xib 没有显示我的自定义字体

我使用一个标签在 LaunchScreen.xib 上用我自定义的字体显示文本。我的自定义字体在 Interface Builder 中显示良好,但是当我在 iPhone 上测试时,字体会恢复为默认字体。

不知道如何修复这个问题,或者这是一个错误。

22950 次浏览

There's no big surprise here. The launch screen is shown at launch time - actually, before launch time - so the font probably hasn't yet loaded.

You could file a bug if you think you have a compelling use case. But I don't really think you do. Why are you showing any text in your launch image? It should be much more bare-bones than that - just enough to give the structure of the opening interface, which will be filled in when the opening interface actually appears. A "blank" screen with the same background color as the initial view controller's background color would be sufficient. You goal is just to provide an alternative to blackness.

A quick workaround is to use an UIImageView and have your text as UIImage on it, literally a picture of your text as .png / .jpeg or similar.

Note: It may take some time before you can see the image, I had to clean the Build Folder and reinstall the app a couple of times in order to see the image.

Another note: If you want to support multiple languages with different texts you will need to have different images for each language using this approach.