| | |
| | | @IBOutlet weak var label_vipInfo: UILabel! |
| | | @IBOutlet weak var view_banner: CommonBannerView! |
| | | @IBOutlet weak var btn_localTap: TapBtn! |
| | | private var layout:WaterFallFlowLayout! |
| | | private var layout:FlowLayout! |
| | | @IBOutlet weak var label_store: UILabel! |
| | | private var items = Array<Any>() |
| | | private var storeModel:HomeStoreModel? |
| | |
| | | override func setUI() { |
| | | view.backgroundColor = UIColor(hexStr: "EEF0F3") |
| | | |
| | | layout = WaterFallFlowLayout() |
| | | layout.cols = 2 |
| | | layout = FlowLayout() |
| | | layout.sectionInset = UIEdgeInsets(top: 14, left: 34, bottom: 14, right: 34) |
| | | layout.delegate = self |
| | | collectionView.collectionViewLayout = layout |
| | | collectionView.delegate = self |
| | | collectionView.dataSource = self |
| | |
| | | |
| | | private func updateUI(){ |
| | | //重置Layout,不然不更新 |
| | | layout = WaterFallFlowLayout() |
| | | layout.itemCount = items.count |
| | | layout.delegate = self |
| | | layout.cols = 2 |
| | | layout.sectionInset = UIEdgeInsets(top: 14, left: 34, bottom: 14, right: 34) |
| | | collectionView.collectionViewLayout = self.layout |
| | | collectionView.reloadData() |
| | | self.collectionView.collectionViewLayout = self.layout |
| | | self.collectionView.reloadData() |
| | | hiddenHUD() |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | extension HomeVC:UICollectionViewDelegate{ |
| | | extension HomeVC:UICollectionViewDelegate,UICollectionViewDelegateWaterFlowLayout{ |
| | | func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, colum section: Int) -> Int { |
| | | return 2 |
| | | } |
| | | |
| | | func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacing section: Int) -> CGFloat { |
| | | return 10 |
| | | } |
| | | |
| | | func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sectionInsetForItems section: Int) -> UIEdgeInsets { |
| | | return UIEdgeInsets(top: 0, left: 34, bottom: 14, right: 34) |
| | | } |
| | | |
| | | func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, itemWidth: CGFloat, caculateHeight indexPath: IndexPath) -> CGFloat { |
| | | let item = items[indexPath.row] |
| | | if let m = item as? HomeStoreConfigModel{ |
| | | return m.cellHeight |
| | | } |
| | | |
| | | if let m = item as? HomeStoreTopBannerModel{ |
| | | return m.cellHeight |
| | | } |
| | | return 200 |
| | | } |
| | | |
| | | func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { |
| | | |
| | | var simpleModel:NormalSimpleModel? |