ios – Present UIHostingController in full screen


My app is predominantly built in UIKit, however, I do have a few views created in SwiftUI.

I am presenting the SwiftUI view using a UIHostingController and my intention is to present this view in full screen.

This is my code:

func present(swiftUIView view: AnyView) {
    let viewController = UIHostingController(rootView: view)
    viewController.modalPresentationStyle = .fullScreen
    present(viewController)
}

The issue is that this doesn’t present the hosting view controller in full screen and still presents it in the default way:

SwiftUI Model presentation

What am I doing wrong and how can I present a SwiftUI view in fullscreen ?

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img