|
|
|
|
|
by Willamin
1491 days ago
|
|
We do use UINagivationController in our app, so that's no issue. Crossing the boundary from UIKit to SwiftUI involves instantiating the SwiftUIView, handing that over to a UIHostingController, then presenting that controller. Something like this: let myView = MySwiftUIView()
let hostingVC = UIHostingController(rootView: myView)
navigationController.present(hostingVC, animated: true)
Crossing the boundary from SwiftUI to UIKit is slightly more boilerplate to write, but it's not too bad. You have to implement either a UIViewControllerRepresentable or a UIViewRepresentable (depends on your needs). Those protocols only needs two functions defined: makeUIView/makeUIViewController and updateUIView/updateUIViewController. For the simplest views and view controllers, you can leave the update definitions empty. |
|