菜鸟教程小白 发表于 2022-12-11 19:50:36

ios - 字体在 Storyboard 中有效,但在 iOS 模拟器(Xcode 8)中无效


                                            <p><p>我一直在处理应用程序的启动屏幕,但遇到了一个问题。我使用的自定义字体(大酒店)显示在 Storyboard 中,但在模拟器中被默认字体替换。应该是 <a href="/image/yuJzD.png" rel="noreferrer noopener nofollow">this</a> , 而是 <a href="/image/rXNfI.png" rel="noreferrer noopener nofollow">this</a>发生。我已经在线尝试了所有内容:将其添加到 plist,设置目标,将其放入 Copy Bundle Resources。我到处寻找,但似乎找不到解决我问题的解决方案。我有什么办法可以解决这个问题吗?难道是因为它是一个启动屏幕?</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>按照以下步骤操作。</p>

<p>(1) 移除您的<strong>自定义字体</strong>。</p>

<p>(2) 重新添加您的字体,例如,右键单击您的项目<strong>--></strong> 添加文件<strong>--></strong> 选择您的自定义字体。 (确保选中<strong>copy items if needed</strong>选项)。</p>

<p>(3) 清理(<strong>⌘+shift+K</strong>) + 构建(<strong>⌘+shift+B</strong>) 你的项目。</p>

<p>要检查自定义字体在运行时是否可用,请添加以下代码:</p>

<pre><code>print(UIFont.fontNames(forFamilyName: &#34;Your_Custom_font_name&#34;)) // if it returns empty array it means fonts are not available on runtime and it is not added correctly.
</code></pre></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 字体在 Storyboard 中有效,但在 iOS 模拟器(Xcode 8)中无效,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/44472007/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/44472007/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 字体在 Storyboard 中有效,但在 iOS 模拟器(Xcode 8)中无效