RainbowBeanPhysicalView.swift 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //
  2. // RainbowBeanPhysical.swift
  3. // RainbowPlanet
  4. //
  5. // Created by 南鑫林 on 2019/6/17.
  6. // Copyright © 2019 RainbowPlanet. All rights reserved.
  7. //
  8. import UIKit
  9. class RainbowBeanPhysicalView: BaseView {
  10. override func setupViews() {
  11. addSubview(collectionView)
  12. }
  13. override func setupLayouts() {
  14. collectionView.snp_makeConstraints { (make) in
  15. make.edges.equalToSuperview()
  16. }
  17. }
  18. private lazy var collectionView: UICollectionView = {
  19. let collectionView = UICollectionView.init(frame: CGRect.zero, collectionViewLayout: collectionViewLayout)
  20. collectionView.backgroundColor = kFEFEFEColor
  21. collectionView.delegate = self;
  22. collectionView.dataSource = self;
  23. collectionView.showsVerticalScrollIndicator = false
  24. collectionView.showsHorizontalScrollIndicator = false
  25. return collectionView
  26. }()
  27. private lazy var collectionViewLayout: UICollectionViewFlowLayout = {
  28. let collectionViewLayout = UICollectionViewFlowLayout.init()
  29. collectionViewLayout.minimumLineSpacing = 15
  30. collectionViewLayout.minimumInteritemSpacing = 0
  31. collectionViewLayout.scrollDirection = .horizontal
  32. return collectionViewLayout
  33. }()
  34. }
  35. extension RainbowBeanPhysicalView: UICollectionViewDelegateFlowLayout,UICollectionViewDataSource {
  36. func numberOfSections(in collectionView: UICollectionView) -> Int {
  37. return 1
  38. }
  39. func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
  40. return 2
  41. }
  42. func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
  43. let cell = RainbowBeanPhysicalCollectionViewCell.cellWith(collectionView: collectionView, indexPath: indexPath)
  44. return cell
  45. }
  46. func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
  47. }
  48. func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
  49. return CGSize(width:(kScreenWidth-28-15)/2, height: 81)
  50. }
  51. func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
  52. return UIEdgeInsets(top:14, left: 14, bottom: 14, right: 14)
  53. }
  54. }