您好我需要在我的操场上添加一些Font,第一个工作,第二个工作,我下载了一个字体,安装了它,添加到资源文件夹中,并在Xcode中添加了这段代码,但它不工作,有人可以帮助我吗?
let fontURL = Bundle.main.url(forResource: "VAGRoundedBold", withExtension: "ttf")
CTFontManagerRegisterFontsForURL(fontURL! as CFURL, CTFontManagerScope.process, nil)
let fontURL3 = Bundle.main.url(forResource: "conduit_itc", withExtension: "ttf")
CTFontManagerRegisterFontsForURL3(fontURL! as CFURL, CTFontManagerScope.process, nil)
buttonYellow.setTitle("Optimism", for: .normal)
buttonYellow.titleLabel?.font = UIFont(name: "VAGRoundedBold", size: 40)
buttonRed.setTitle("Strenght", for: .normal)
buttonRed.titleLabel?.font = UIFont(name:"conduit_itc", size: 40)
EDIT。我不知道问题是什么,但从dafont工作下载,从其他网站下载不起作用
答案 0 :(得分:0)
第二:打开Info.plist
并添加
<key>UIAppFonts</key>
<array>
<string> VAGRoundedBold.ttf</string>
</array>
上次:使用
let yourFont = UIFont(name: "VAGRoundedBold", size: <your_size>)!