Skip to content

briancordanyoung/OverlayPlay

Repository files navigation

An Experiment in Mixing UIKit and SwiftUI layout

This little example project shows the beginnings of a class, OverlayViewController. It is designed to be added as a child view controller and presents itself like a drawer at the bottom of the screen. It is generic and takes a SwiftUI View which it hosts and presents within itself.

The constraints for OverlayViewController define a padding around the UIHostingController.view. The height of the OverlayViewController.view should be established by the height of the hosted SwiftUI ExampleView. When the overlay is initially presented, there is mysterious extra top and bottom padding around the ExampleView. If the app is forced to layout again by rotating it to landscape and back, the views will be positioned correctly.

Question

Is there a way to force the UIKit and SwiftUI layout systems to position the views correctly when initially presenting them?

Initial Layout
Correct Layout

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published