當前文章的短網址連結為: https://unos.top/4uq1
假如需要引入Google Fonts中的自定义字体到IOS项目中
https://fonts.google.com/specimen/Nunito
首先,下载字体文件

假设要使用Bold和Regular这两种字体

在项目中创建Resources Group和Fonts Sub-Group,然后拖入需要的字体文件(如果需要所有的字体文件,那就全部拖入Fonts分组中)

然后,打开项目配置文件xcodeproj,配置Info选项下面的信息,将两个字体配置到 Fonts provided by application 中

上述步骤配置之后,项目中会出现Info.plist文件显示,选中后内容如下

最后,在代码中进行调用即可
.font(.custom("Nunito-Regular", size: 25))
Swift若要跟动态类型配合使用自定义字体,这样调用
.font(.custom("Nunito-Regular", size: 35, relativeTo: .largeTitle))
Swift.largetitle字体类型将从35pt开始,并自动缩放。