Skip to content

Instantly share code, notes, and snippets.

@sturdysturge
Created February 4, 2021 22:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sturdysturge/5eb85a14098bd3d4467df3e37c7d9cc3 to your computer and use it in GitHub Desktop.
Save sturdysturge/5eb85a14098bd3d4467df3e37c7d9cc3 to your computer and use it in GitHub Desktop.
import SwiftUI
struct ContentView : View {
@State var text = ""
var body: some View {
VStack {
TextField("Add text here", text: $text)
UIKitVC(text: $text)
}
.padding()
}
}
struct UIKitVC: UIViewControllerRepresentable {
@Binding var text: String
func makeUIViewController(context: Context) -> ViewController {
ViewController()
}
func updateUIViewController(_ uiViewController: ViewController, context: Context) {
uiViewController.labelText.text = text
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment