ios – Take away padding when utilizing UIHostingConfiguration in cell?


I’m attempting to determine learn how to take away the padding I get once I use UIHostingConfiguration to make use of a SwiftUI view in a UICollectionView. For instance utilizing this code:

If I add a border to the CellView:

/// Create a cell registration of kind UICollectionViewCell with `ToDoListItem` that will likely be used to offer the gathering view cells.
/// This can
let cellRegistration = UICollectionView.CellRegistration<UICollectionViewCell, ToDoListItem> { cell, indexPath, merchandise in
        cell.contentConfiguration = UIHostingConfiguration {
            CellView(toDoListItem: merchandise)
                .border(.pink)// <-- I need this border to match the blue border...
        cell.layer.borderWidth = 1
        cell.layer.borderColor = //<-- this exhibits the precise cell dimension I need my swiftui view to fill

It exhibits the padding I’m speaking about:

enter image description here

I’ve the identical habits in different initiatives. I need the SwiftUI view inside UIHostingConfiguration closure to fill the complete area of the cell in order that on this case that pink border would overlap the blue border.

How can I try this?


Leave a Reply