我已经尝试了下面的代码来添加自定义字体到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谢谢…
发布于 2016-12-06 23:21:14
我已经调查过这个问题了。看起来添加的importFonts()函数仅供内部使用。如果您想添加自定义字体,您应该询问imglyKit开发人员,或者您可以使用swizzle availableFontsList方法添加自定义字体。
您可以在InstanceFactory on GitHub类中找到此方法。类方法混合示例:Gist
https://stackoverflow.com/questions/40907128
复制相似问题