gpt4 book ai didi

ios - 如何在 Swift 中重用字体?

转载 作者:搜寻专家 更新时间:2023-10-31 19:35:57 26 4
gpt4 key购买 nike

假设我有这个自定义字体 字体.ttf

我有两个项目。 /projects/A 中的项目 A 和 /projects/B

中的项目 B

我不想在项目之间复制粘贴此字体。

我创建了一个 cocoa touch 框架并向其中添加了 font.ttf。然后在项目 A 和 B 中重用该框架。但它不起作用。可能吗?

最佳答案

根据这个thread , 你可以试试

let bundle = Bundle(identifier: "frameworkIdentifier")!

let url = bundle.url(forResource: "fontName", withExtension: "ttf")!

if let dataProvider = CGDataProvider(url: url as CFURL) {
let font = CGFont(dataProvider)
print(font)
}

//

enter image description here

//

enter image description here

关于ios - 如何在 Swift 中重用字体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51706813/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com