Navigate from UIViewController to SwiftUI View

Viewed 844

I see a lot online about how to navigate to a UIViewController from a SwiftUI view, but not much on how to navigate from a UIViewController to a SwiftUI view. Anyone know how to do this?

1 Answers

You can do this as you do with UIViewcontroller, But SwiftUIView is represented with UIHostingController in UIKit

import SwiftUI
    
...

let hostingController = UIHostingController(rootView: YourSwiftUIView())
navigationController?.pushViewController(hostingController, animated: true)
Related