SwiftUI into UIKit into SwiftUI

A half modal is an interface ingredient that may be helpful in a number of completely different conditions. Sadly, it can’t be applied throughout the SwiftUI framework itself.
However we current you a approach to bypass this limitation and create a Half Modal with all of the options of the SwiftUI setting.
Usually, to indicate SwiftUI components inside UIKit it is best to use a UIHostingController
. By subclassing it you may customise it at will.
On this case, it’s a half-modal, that may be resized to full-screen.
The precise construction of the modal should conform to UIViewControllerRepresentable
.
In our challenge, we used a ViewBuilder
to keep away from the addition of the Storyboard.
Now you may simply name your modal inside SwiftUI as a standard SheetView.


Right here’s the code to create this little customized ingredient to develop the chances of your interface, take pleasure in!
Thanks for studying.
Writers Andrea Masturzo, Cristian Cimbir
All code assets for this text can be found on GitHub: