Skip to content

Instantly share code, notes, and snippets.

View mattadatta's full-sized avatar

Matthew Brown mattadatta

  • Ottawa, ON, Canada
View GitHub Profile
@mattadatta
mattadatta / CollectionView.swift
Last active August 4, 2024 08:41
CollectionView.swift - UIKit's UICollectionView implemented in SwiftUI using UIViewControllerRepresentable
//
// (See usage below implementation)
//
// SwiftUI `CollectionView` type implemented with UIKit's UICollectionView under the hood.
// Requires `UIViewControllerRepresentable` over `UIViewRepresentable` as the type that allows
// for SwiftUI `View`s to be added as subviews of UIKit `UIView`s at all bridges this gap as
// the `UIHostingController`.
//
// Not battle-tested yet, but seems to be working well so far.
// Expect changes.