UIViewRepresentable and safe area insets.

Hi everyone!

We struggle to get the safe area insets from SwiftUI context into our custom UIScrollView subclass. It has to go under the custom top navigation bar and bottom toolbars. In SwiftUI, our code looks like the following:

struct ContentView: View
{
	var body: some View
	{
		CustomScrollView()
			.ignoresSafeArea()				// Spread it out from top to bottom
			.safeAreaInset(edge: .top)	// Add custom nav bar at top
			{
				CustomNavigationBar()
			}
			.safeAreaInset(edge: .bottom)	// Add custom toolbar at bottom
			{
				CustomToolbar()
			}
	}
}

The layout looks fine, except that CustomScrollView, which is a UIScrollView subclass, does not inherit the proper safeAreaInsets from SwiftUI. We tried to examine every value reachable in Context from updateUIView(_, context:) within our UIViewRepresentable, but no luck.

Are we missing something here?

Should a UIScrollView subclass inherit safe area insets automatically, or should we explicitly get them from GeometryReader?

We appreciate any clues or suggestions that will help us solve this problem.

Thank you!

I have no answer unfortunately but would like to know if you solved this somehow?

UIViewRepresentable and safe area insets.
 
 
Q