Commit d7e4e33f authored by 刘俊宏's avatar 刘俊宏

同上,完善

parent 5e620756
...@@ -13,7 +13,7 @@ class GoodsManageListVC: BaseViewController, UICollectionViewDelegate, UICollect ...@@ -13,7 +13,7 @@ class GoodsManageListVC: BaseViewController, UICollectionViewDelegate, UICollect
var collection : UICollectionView? = nil var collection : UICollectionView? = nil
let layout = UICollectionViewFlowLayout() var layout = UICollectionViewFlowLayout()
private let animations = [AnimationType.from(direction: .bottom, offset: 100.0)] private let animations = [AnimationType.from(direction: .bottom, offset: 100.0)]
private var items = [Any?]() private var items = [Any?]()
...@@ -21,6 +21,9 @@ class GoodsManageListVC: BaseViewController, UICollectionViewDelegate, UICollect ...@@ -21,6 +21,9 @@ class GoodsManageListVC: BaseViewController, UICollectionViewDelegate, UICollect
@IBOutlet weak var contentView: UIView! @IBOutlet weak var contentView: UIView!
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
layout.headerReferenceSize = CGSize(width: 375, height: 50)
self.collection = UICollectionView(frame: CGRect(x: 0, y: 0, width: 0, height: 0), collectionViewLayout: layout) self.collection = UICollectionView(frame: CGRect(x: 0, y: 0, width: 0, height: 0), collectionViewLayout: layout)
self.collection?.delegate = self self.collection?.delegate = self
...@@ -33,6 +36,9 @@ class GoodsManageListVC: BaseViewController, UICollectionViewDelegate, UICollect ...@@ -33,6 +36,9 @@ class GoodsManageListVC: BaseViewController, UICollectionViewDelegate, UICollect
}) })
self.collection?.register(UINib(nibName: "GoodsCollectionViewCell", bundle: nil), forCellWithReuseIdentifier: "GoodsCollectionViewCell") self.collection?.register(UINib(nibName: "GoodsCollectionViewCell", bundle: nil), forCellWithReuseIdentifier: "GoodsCollectionViewCell")
self.collection?.register(UICollectionReusableView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: "headerIdentifier")
DispatchQueue.main.asyncAfter(deadline: .now() + 0.33) { DispatchQueue.main.asyncAfter(deadline: .now() + 0.33) {
self.items = Array(repeating: nil, count: 11) self.items = Array(repeating: nil, count: 11)
self.collection?.reloadData() self.collection?.reloadData()
...@@ -45,6 +51,23 @@ class GoodsManageListVC: BaseViewController, UICollectionViewDelegate, UICollect ...@@ -45,6 +51,23 @@ class GoodsManageListVC: BaseViewController, UICollectionViewDelegate, UICollect
} }
} }
func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
let headerV = collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: "headerIdentifier", for: indexPath)
let headerLbl = UILabel(frame: CGRect(x: 15, y: 0, width: 100, height: 50))
headerLbl.text = "共x件商品"
headerV.addSubview(headerLbl)
return headerV
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
return CGSize.init(width: 375, height: 50)
}
func numberOfSections(in collectionView: UICollectionView) -> Int { func numberOfSections(in collectionView: UICollectionView) -> Int {
return 1 return 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment