Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. override func viewDidLoad() {
  2. super.viewDidLoad()
  3. setupCollectionViewLayout()
  4. setupCollectionView()
  5. setupMenuBar()
  6. }
  7.  
  8. var headerView: HeaderView?
  9.  
  10. fileprivate func setupCollectionViewLayout() {
  11. if let layout = collectionViewLayout as? UICollectionViewFlowLayout {
  12. layout.sectionInset = .init(top: padding, left: padding, bottom: padding, right: padding)
  13. }
  14. }
  15.  
  16. fileprivate func setupCollectionView() {
  17. self.collectionView.backgroundColor = .white
  18.  
  19. //For iPhone X's make sure it doesn't cover the swipe bar at bottom
  20. self.collectionView.contentInsetAdjustmentBehavior = .never
  21.  
  22. // Register cell classes
  23. self.collectionView!.register(UICollectionViewCell.self, forCellWithReuseIdentifier: cellId)
  24.  
  25. self.collectionView.register(HeaderView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: headerId)
  26.  
  27. self.collectionView.contentInset = UIEdgeInsets(top: 60, left: 0, bottom: 0, right: 0)
  28. self.collectionView?.scrollIndicatorInsets = UIEdgeInsets(top: 60, left: 0, bottom: 0, right: 0)
  29. }
  30.  
  31. let menuBar: MenuBar = {
  32. let mb = MenuBar()
  33. return mb
  34. }()
  35. fileprivate func setupMenuBar() {
  36. view.addSubview(menuBar)
  37. view.addConstraintWithFormat(format: "H:|[v0]|", views: menuBar)
  38. view.addConstraintWithFormat(format: "V:|-400-[v0(50)]|", views: menuBar)
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement