简体   繁体   English

自定义字体不起作用Xcode

[英]Custom Font Not Working Xcode

I'm trying to add a custom font to my iOS app and I have followed all the necessary steps(plist, copy build resources etc). 我正在尝试向我的iOS应用添加自定义字体,并且我已按照所有必需的步骤进行操作(plist,复制构建资源等)。 The font is working in the Builder Interface but when I run it all that shows up is boxes with ? 字体正在Builder界面中运行,但是当我运行它时,所有显示的是带有?的框。 in them. 在他们中。 Please help this has been an issue for almost a week now. 请帮助,这已经有将近一个星期了。 !( https://imgur.com/a/rO50c9Q ) !( https://imgur.com/a/rO50c9Q

Make sure you checked Target Membership 确保您已选中目标会员资格

在此处输入图片说明

From what you described you seemed to have followed the correct steps. 根据您的描述,您似乎已经遵循了正确的步骤。

Maybe it's the font name that's causing the issue? 可能是字体名称引起了问题?

According to this tutorial: Add Custom Fonts To Your App 根据本教程: 将自定义字体添加到您的应用程序

the font name may not be what you expect. 字体名称可能不是您所期望的。 It could be very different than any of the visible font names that you can see 它可能与您可以看到的任何可见字体名称有很大不同

在此处输入图片说明

He says add this code in viewDidLoad to of any of your view controllers to find all the font names that your app is currently using. 他说,将此代码添加到viewDidLoad中的任何视图控制器中,以查找您的应用当前正在使用的所有字体名称。 There is a possibility the font name you entered might be different from the font name the app has it listed as: 您输入的字体名称可能与应用列出的字体名称不同:

override func viewDidLoad() {
    super.viewDidLoad()

    for family: String in UIFont.familyNames {

        print("\(family)")
        for names: String in UIFont.fontNames(forFamilyName: family)
        {
            print("== \(names)")
        }
    }
}

在此处输入图片说明

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

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