简体   繁体   English

如何在Xcode中将SFPro字体用于部署目标9.3?

[英]How can you use SFPro font in Xcode for deployment target 9.3?

Xcode doesn't come with SFPro by default if we set deployment target as 9.3. 如果我们将部署目标设置为9.3,则Xcode默认不附带SFPro。 The system font is SF. 系统字体为SF。 I am doubtful if loading SFPro font manually will work even if I have not set deployment target as 11. 我不确定手动加载SFPro字体是否可以工作,即使我没有将部署目标设置为11。

You can download the fonts here: https://developer.apple.com/fonts/ 您可以在此处下载字体: https : //developer.apple.com/fonts/

Add the font files to your project and declare them in Project Info settings with Fonts provided by application : 将字体文件添加到您的项目中,并使用Fonts provided by application在“项目信息”设置中声明它们:

在此处输入图片说明

Then use the font with code like this (for example): 然后使用带有以下代码的字体(例如):

    if let customFont = UIFont(name: "SFProDisplay-Regular", size: 32) {
        theLabel.font = customFont
    }

To find the actual names of the fonts, you can use this code: 要查找字体的实际名称,可以使用以下代码:

    for family in UIFont.familyNames {

        let sName: String = family as String
        print("family: \(sName)")

        for name in UIFont.fontNames(forFamilyName: sName) {
            print("name: \(name as String)")
        }
    }

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

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