Ios 使用UIFont在Xcode中使用自定义粗体字体

Ios 使用UIFont在Xcode中使用自定义粗体字体,ios,swift,xcode,Ios,Swift,Xcode,我已将所有类型的自定义字体导入Xcode 但当我想在UIFont中使用它时,我得到了一个错误 我使用的方法如下: let appearance = UITabBarItem.appearance() let attributes = [NSAttributedString.Key.font: UIFont(name: "IRANSansMobile(FaNum)_Bold", size: 10), NSAttributedString.Key.

我已将所有类型的自定义字体导入Xcode 但当我想在UIFont中使用它时,我得到了一个错误

我使用的方法如下:

let appearance = UITabBarItem.appearance()
    let attributes = [NSAttributedString.Key.font: UIFont(name: "IRANSansMobile(FaNum)_Bold", size: 10),
                      NSAttributedString.Key.foregroundColor: UIColor.black]
    appearance.setTitleTextAttributes(attributes as [NSAttributedString.Key : Any], for: .normal)
当我从字体名称的末尾删除粗体时,它可以正常工作,但不是粗体样式。
请帮我解决它

代码以打印出所有可用的UIFonts。检查字体系列的名称和字体名称。使用此名称作为您的字体名称

let fontFamilyNames = UIFont.familyNames()
        for familyName in fontFamilyNames {
            //Check the Font names of the Font Family
            let names = UIFont.fontNamesForFamilyName(familyName )
            // Write out the Font Family name and the Font's names of the Font Family
            print("Font == \(familyName) \(names)")
        }

我猜你用的是文件名而不是postscript名称?将其安装到Mac电脑中,打开Font Books.app,选择粗体字体,然后选择Cmd+I显示字体信息,并使用显示的postscript名称。否则,在iOS中,添加其他代码以获取所有字体系列枚举并查找粗体版本。对于字体书籍。应用程序版本:对于编码版本: