SHRichTextEditorTools 5.1.6

SHRichTextEditorTools 5.1.6

测试已测试
Lang语言 SwiftSwift
许可 MIT
发布最新发布2021年1月
SPM支持 SPM

hsusmita 维护。



  • Susmita Horrow

#SHRichTextEditorTools 这是一个有助于构建富文本编辑器的扩展集合。

#安装

您可以使用基本设置并创建自己的编辑器,然后在 pod 文件中添加以下行:
pod 'SHRichTextEditorTools/Core', '~> 4.0.7'

如果您想要使用预配置的文本编辑器,您必须在 pod 文件中添加以下行:pod 'SHRichTextEditorTools/SHRichTextEditor', '~> 4.0.7'

#使用

基本

此库包含一个基本编辑器 SHRichTextEditor,包括基本功能,如 粗体斜体缩进 特性。

let textEditor = SHRichTextEditor(textView: self.textView)
textEditor.toolBarItems = [textEditor.boldBarItem(), textEditor.italicBarItem(), textEditor.indentationBarItem()]

自定义色彩

let textEditor = SHRichTextEditor(textView: self.textView, defaultTintColor: UIColor.gray, selectedTintColor: UIColor.green)

自定义栏按钮

let boldBarItem = self.textEditor.boldBarItem(type: .title(title: "Button")) { (button, selected) in
	button.barButtonItem.tintColor = selected ? UIColor.gray : UIColor.green
}
self.textEditor.toolBarItems = [boldBarItem]

在这里类型由以下枚举定义:

public enum ButtonType {
	case title(title: String)
	case attributed(title: String, attributes: [UIControlState.RawValue: [NSAttributedStringKey : Any]])
	case image(image: UIImage)
}