适用于 iOS 的富文本编辑器 (SwiftUI)

文本编辑器

      

预览

import TextEditor

struct ContentView: View {
    let richText = NSMutableAttributedString()
    
    var body: some View {
        ZStack {
            Color(hex: "97DBAE")
                .edgesIgnoringSafeArea(.all)
            RichTextEditor(richText: richText)
                .padding(10)
                .background(
                    Rectangle()
                        .stroke(lineWidth: 1)
                )
                .padding()
        }
    }
}

Preview Image

Usage

Add the following lines to your or use Xcode “Add Package Dependency” menu.Package.swift

.package(name: "TextEditor", url: "https://github.com/nothingsh/TextEditor", ...)

Todo

  • Add font selection
  • Make Input Accessory View Configurable

GitHub

点击跳转