Skip to content

Instantly share code, notes, and snippets.

@karigrooms
Created February 23, 2021 20:18
Show Gist options
  • Save karigrooms/7e3f7b6b610b13f42089597df5f352f0 to your computer and use it in GitHub Desktop.
Save karigrooms/7e3f7b6b610b13f42089597df5f352f0 to your computer and use it in GitHub Desktop.
Blog post: SwiftUI with UICollectionView - 10. Update our cell to subclass SwiftUICollectionViewCell
import SwiftUI
import UIKit
class MyCollectionViewCell: SwiftUICollectionViewCell<Card> {
static var reuseIdentifier = "MyCollectionViewCell"
typealias Content = Card.Content
func configure(with content: Content, parent: UIViewController) {
embed(in: parent, withView: Card(content: content))
host?.view.frame = self.contentView.bounds
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment