xcode LaunchScreen.xib 不显示我的自定义字体

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

LaunchScreen.xib not displaying my custom font

iosxcode

提问by user3781632

I'm using a label to display text with my custom font on LaunchScreen.xib. My custom font shows up fine in the Interface Builder, but when I test it on my iPhone the font reverts back to the default font.

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

Not sure how to fix this or if it's a bug.

不知道如何解决这个问题,或者它是否是一个错误。

采纳答案by matt

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 anytext 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.

如果您认为自己有一个引人注目的用例,则可以提交错误。但我真的不认为你会这样做。为什么在启动图像中显示任何文本?它应该比这更简单 - 足以给出打开界面的结构,当打开界面实际出现时将填充它。与初始视图控制器的背景颜色具有相同背景颜色的“空白”屏幕就足够了。您的目标只是提供黑色的替代品。

回答by Gustavo Vollbrecht

A quick workaround is to use an UIImageViewand have your text as UIImageon it, literally a picture of your text as .png/ .jpegor similar.

一个快速的解决方法是使用 anUIImageView并将您的文本UIImage放在上面,字面上是您的文本图片为.png/.jpeg或类似的。

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.

另一个注意事项:如果您想支持具有不同文本的多种语言,您将需要使用这种方法为每种语言使用不同的图像。