ios – Take away padding when utilizing UIHostingConfiguration in cell?

[ad_1]

I’m making an attempt to determine the right way to take away the padding I get after I use UIHostingConfiguration to make use of a SwiftUI view in a UICollectionView. For instance utilizing this code:

https://github.com/mvemjsun/CollectionView

If I add a border to the CellView:

/// Create a cell registration of sort 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(.purple)// <-- I would like this border to match the blue border...
        }
        cell.layer.borderWidth = 1
        cell.layer.borderColor = UIColor.blue.cgColor //<-- this exhibits the precise cell measurement I would like my swiftui view to fill
    }
}
    

It exhibits the padding I’m speaking about:

enter image description here

I’ve the identical habits in different tasks. I would like the SwiftUI view inside UIHostingConfiguration closure to fill the whole area of the cell in order that on this case that purple border would overlap the blue border.

How can I do this?

[ad_2]

Leave a Reply