-
-
Save sturdysturge/2dd7ca76fd1c1a2d81c64334efabff7c to your computer and use it in GitHub Desktop.
MultilineTextView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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