Skip to content

Instantly share code, notes, and snippets.

@sturdysturge
Created June 26, 2020 15:28
Show Gist options
  • Save sturdysturge/2dd7ca76fd1c1a2d81c64334efabff7c to your computer and use it in GitHub Desktop.
Save sturdysturge/2dd7ca76fd1c1a2d81c64334efabff7c to your computer and use it in GitHub Desktop.
MultilineTextView
struct ContentView : View {
@State private var text = ""
var body: some View {
MultilineTextView(text: $text)
}
}
struct MultilineTextView: UIViewRepresentable {
@Binding var text: String
func makeUIView(context: Context) -> UITextView {
let view = UITextView()
view.isScrollEnabled = true
view.isEditable = true
view.isUserInteractionEnabled = true
return view
}
func updateUIView(_ uiView: UITextView, context: Context) {
uiView.text = text
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment