SwiftUI UIHostingController - unable to disable safe area

Number:rdar://FB8176223 Date Originated:27/7/20
Status:Open Resolved:
Product:SwiftUI Framework Product Version:13.6
Classification: Reproducible:
When embedding a SwiftUI view into UIKit, there is no way to disable SafeArea behaviour. 

This is important within UITableView/UICollectionView... sometimes when a SwiftUI UIHostingController is added to the hierarchy, it happens to be at the boundary of a safeArea in screen bounds and so applies dodging/expanding behaviour depending on the `edgesIgnoringSafeArea` modifier, even though within a scrollView this doesn't make sense.

There is a `disableSafeArea` bool on UIHostingView, however this is private. The .edgesIgnoringSafeArea modifier does not achieve this purpose as it will extend the frame if enabled / dodge the safe area if set to `[]`

Is there a way to achieve this?



Had the same problem when using the UIHostingController as a subview for an MKAnnotationView.

This article describes the workaround in the "Fixing cell frames" paragraph:


By jiri.bucek at Aug. 9, 2022, 2:02 p.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!