Alex Styl
04/13/2024, 7:09 AMAlex Styl
04/13/2024, 7:10 AMclass ShareViewController: UIViewController {
...
override func viewDidLoad() {
super.viewDidLoad()
//... at the end of viewDidLoad()
let rootView = ComposeView()
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(.blue)
let controller = UIHostingController(rootView: rootView)
let controller = controller
controller.view.frame = self.view.bounds
controller.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
controller.view.backgroundColor = .clear
addChild(controller)
view.addSubview(controller.view)
controller.didMove(toParent: self)
}
}
struct ComposeView: UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> UIViewController {
MainViewControllerKt.MainViewController()
}
func updateUIViewController(_ uiViewController: UIViewController, context: Context) {}
}
Alex Styl
04/13/2024, 7:11 AMMainViewController()
directly instead of creating a UIHostingController
and the results are identical.Alex Styl
04/13/2024, 7:39 AM