UIHostingController + SafeArea
Sep 25, 2023
Here’s how you can ignore the safeArea when using a UIHostingController.
The Problem
You are ignoring the safeArea in the most outter view, but when you display it using UIHostingController — it doesn’t work.
The Solution
Add a .frame(maxWidth: .infinity) modifier to your view. Take that view and wrap it inside a ZStack and add the background and ignoreSafeArea modifier to the ZStack.
That’s it. No private _disableSafeArea apis, no hacky extensions. Just pure SwiftUI :)