gpt4 book ai didi

ios - 如何使用 Swift 将自定义字体添加到 iOS 中的 imglyKit SDK 中?

转载 作者:搜寻专家 更新时间:2023-10-31 08:06:10 25 4
gpt4 key购买 nike

我已尝试使用以下代码将自定义字体添加到 imglyKit SDK 中,但未添加自定义字体。我还将 .ttf 文件作为资源放入 info.plist 文件中。

        let sampleImage = image.image

let configuration = Configuration() { builder in
FontImporter.init().importFonts()

builder.configurePhotoEditorViewController({ (editPhotoOption) in

editPhotoOption.allowedPhotoEditorActions = [.text]

editPhotoOption.actionButtonConfigurationClosure = {cell, _ in

cell.captionLabel.text = "Add Text"
//cell.backgroundColor = UIColor.red
}
editPhotoOption.backgroundColor = UIColor.brown
editPhotoOption.allowsPreviewImageZoom = false
})

builder.configureToolStackController({ (toolStackOption) in

toolStackOption.mainToolbarBackgroundColor = UIColor.red
toolStackOption.secondaryToolbarBackgroundColor = UIColor.brown

})

builder.configureTextFontToolController({ (textFontToolOption) in

var fontArray = [String]()
fontArray = ["AlexBrush_Regular.ttf", "Arabella.ttf"]
textFontToolOption.accessibilityElements = fontArray

textFontToolOption.actionButtonConfigurationClosure = { cell, _ in
cell.backgroundColor = UIColor.red
}
})


builder.configureTextToolController({ (textToolOption) in

textToolOption.textViewConfigurationClosure = { label in

label.textAlignment = NSTextAlignment.center
}
})
}

let photoEditViewController = PhotoEditViewController(photo: sampleImage!, configuration: configuration)



let toolStackController = ToolStackController(photoEditViewController: photoEditViewController)
toolStackController.delegate = self
toolStackController.navigationController?.view.backgroundColor = UIColor.red
present(toolStackController, animated: true, completion: nil)

请帮我添加自定义字体

我还使用 FontImporter 类按照这里的指南加载自定义字体 http://static.photoeditorsdk.com/docs/ios/Classes/FontImporter.html谢谢...

最佳答案

我已经调查了这个问题。看起来 importFonts() 函数只是为了内部使用而添加的。如果您想添加自定义字体,您应该询问 imglyKit 开发人员,或者您可以调整 availableFontsList 方法来添加您的自定义字体。

你可以在InstanceFactory on GitHub类中找到这个方法.类方法混合示例:Gist

关于ios - 如何使用 Swift 将自定义字体添加到 iOS 中的 imglyKit SDK 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40907128/

25 4 0
文章推荐: eclipse - <header> 标记在 eclipse 中无法识别
文章推荐: java - ReplaceAll 和 "不替换
文章推荐: html - pdf 保存一个更具描述性的文件名?
文章推荐: java - 如何将字符数组转换为字符串数组
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com