Created
June 18, 2021 17:41
-
-
Save froggomad/0e95f04438bcef2a05476eba9919db41 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class TitledCollectionViewController: UIViewController { | |
lazy var fruitView = TitledCollectionView(produce: .fruit) | |
lazy var vegetableView = TitledCollectionView(produce: .vegetable) | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
setupViews() | |
} | |
func setupViews() { | |
view.backgroundColor = .systemBackground | |
view.addSubview(fruitView) | |
view.addSubview(vegetableView) | |
NSLayoutConstraint.activate([ | |
fruitView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 20), | |
fruitView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor, constant: -20), | |
fruitView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor, constant: 20), | |
fruitView.heightAnchor.constraint(equalToConstant: TitledCollectionView.Layout.heightConstant), | |
vegetableView.topAnchor.constraint(equalTo: fruitView.safeAreaLayoutGuide.bottomAnchor, constant: 20), | |
vegetableView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor, constant: -20), | |
vegetableView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor, constant: 20), | |
vegetableView.heightAnchor.constraint(equalToConstant: TitledCollectionView.Layout.heightConstant), | |
]) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment