SwiftyMarkdown icon indicating copy to clipboard operation
SwiftyMarkdown copied to clipboard

support with swiftui

Open reinaldoriant opened this issue 2 years ago • 1 comments

hello, can this support in swift UI, and do you have a sample ?

reinaldoriant avatar Sep 06 '21 02:09 reinaldoriant

You can use any implementation of UIViewRepresentable. Here is simple one

struct UIKTextView: UIViewRepresentable {
    @Binding var text: NSAttributedString

    func makeUIView(context: Context) -> UITextView {
        UITextView()
    }

    func updateUIView(_ uiView: UITextView, context: Context) {
        uiView.attributedText = text
    }
}

And then

UIKTextView(text: .constant(SwiftyMarkdown(string: "some **bold** markdown text").attributedString()))

rastislv avatar Nov 09 '21 14:11 rastislv