Skip to content

Instantly share code, notes, and snippets.

@stevencurtis
Created July 2, 2020 17:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevencurtis/e510eaab083336e68426131c528c77b8 to your computer and use it in GitHub Desktop.
Save stevencurtis/e510eaab083336e68426131c528c77b8 to your computer and use it in GitHub Desktop.
featuresection
struct FeatureSection: LayoutSection {
func configureCell(collectionView: UICollectionView, indexPath: IndexPath, item: AnyHashable, position: Int) -> UICollectionViewCell {
guard let cell = collectionView.dequeueReusableCell(
withReuseIdentifier: String(describing: AppFeaturedCollectionViewCell.self), for: indexPath) as? AppFeaturedCollectionViewCell else {
fatalError("Unable to create new cell") }
if let item = item as? AppDataModel {
cell.configure(with: item, final: false)
}
return cell
}
var layoutSection: NSCollectionLayoutSection = {
let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: .fractionalHeight(1))
let item = NSCollectionLayoutItem(layoutSize: itemSize)
let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(0.9), heightDimension: .fractionalHeight(0.35))
let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitems: [item])
let section = NSCollectionLayoutSection(group: group)
section.orthogonalScrollingBehavior = .groupPagingCentered
return section
}()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment