Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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