-
-
Save laevandus/d3e9383dc78036c52a91614c27d7de8e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final class ListViewController: UIViewController { | |
private func makeCollectionView() -> UICollectionView { | |
var configuration = UICollectionLayoutListConfiguration(appearance: .insetGrouped) | |
configuration.headerMode = .supplementary | |
let layout = UICollectionViewCompositionalLayout.list(using: configuration) | |
let view = UICollectionView(frame: .zero, collectionViewLayout: layout) | |
view.backgroundColor = .systemBackground | |
view.translatesAutoresizingMaskIntoConstraints = false | |
return view | |
} | |
private lazy var collectionView = makeCollectionView() | |
override func loadView() { | |
title = "Palettes" | |
view = UIView(frame: .zero) | |
view.addSubview(collectionView) | |
NSLayoutConstraint.activate([ | |
collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor), | |
collectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor), | |
collectionView.topAnchor.constraint(equalTo: view.topAnchor), | |
collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor) | |
]) | |
viewModel.reloadContent(in: dataSource) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment