加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-14 04:56:18 所属栏目:百科 来源:网络整理
导读:我尝试了以下代码将自定义字体添加到imglyKit SDK中,但没有添加自定义字体.我还将.ttf文件作为资源放入info.plist文件中. let sampleImage = image.image let configuration = Configuration() { builder in FontImporter.init().importFonts() builder.conf
我尝试了以下代码将自定义字体添加到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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读