|
@@ -51,7 +51,6 @@ class ProductDetailProductSkuTableViewCell: UITableViewCell {
|
|
|
self.selectionStyle = .none
|
|
|
addSubview(bgView)
|
|
|
bgView.addSubview(skuLabel)
|
|
|
- bgView.addSubview(skuCollectionView)
|
|
|
bgView.addSubview(goImageView)
|
|
|
bgView.addSubview(selectedLabel)
|
|
|
|
|
@@ -81,13 +80,8 @@ class ProductDetailProductSkuTableViewCell: UITableViewCell {
|
|
|
skuLabel.snp.makeConstraints { (make) in
|
|
|
make.centerY.equalToSuperview()
|
|
|
make.left.equalTo(selectedLabel.snp.right).offset(27)
|
|
|
- }
|
|
|
-
|
|
|
- skuCollectionView.snp.makeConstraints { (make) in
|
|
|
- make.top.equalToSuperview()
|
|
|
- make.right.equalTo(goImageView.snp.left).offset(-10)
|
|
|
- make.left.equalTo(selectedLabel.snp.right).offset(20)
|
|
|
- make.height.equalTo(44)
|
|
|
+ make.right.equalTo(-14)
|
|
|
+ make.bottom.equalToSuperview()
|
|
|
}
|
|
|
|
|
|
iconCollectionView.snp.makeConstraints { (make) in
|
|
@@ -125,29 +119,6 @@ class ProductDetailProductSkuTableViewCell: UITableViewCell {
|
|
|
return skuLabel
|
|
|
}()
|
|
|
|
|
|
- private lazy var skuCollectionView: UICollectionView = {
|
|
|
- let skuCollectionView = UICollectionView.init(frame: CGRect.zero, collectionViewLayout: skuCollectionViewLayout)
|
|
|
- skuCollectionView.backgroundColor = UIColor.white
|
|
|
- skuCollectionView.delegate = self;
|
|
|
- skuCollectionView.dataSource = self;
|
|
|
- skuCollectionView.showsVerticalScrollIndicator = false
|
|
|
- skuCollectionView.showsHorizontalScrollIndicator = false
|
|
|
- skuCollectionView.cornerRadius = 4
|
|
|
- skuCollectionView.masksToBounds = true
|
|
|
- skuCollectionView.isHidden = true
|
|
|
- return skuCollectionView
|
|
|
- }()
|
|
|
-
|
|
|
- private lazy var skuCollectionViewLayout: UICollectionViewFlowLayout = {
|
|
|
- let skuCollectionViewLayout = UICollectionViewFlowLayout.init()
|
|
|
- skuCollectionViewLayout.minimumLineSpacing = 0
|
|
|
- skuCollectionViewLayout.minimumInteritemSpacing = 0
|
|
|
- skuCollectionViewLayout.estimatedItemSize = CGSize(width: 72, height: 25)
|
|
|
- skuCollectionViewLayout.scrollDirection = .vertical
|
|
|
-
|
|
|
- return skuCollectionViewLayout
|
|
|
- }()
|
|
|
-
|
|
|
private lazy var selectedLabel : UILabel = {
|
|
|
let selectedLabel = UILabel()
|
|
|
selectedLabel.text = "选择"
|
|
@@ -201,19 +172,6 @@ class ProductDetailProductSkuTableViewCell: UITableViewCell {
|
|
|
//加载数据
|
|
|
func reloadData() {
|
|
|
|
|
|
- //collectionView重新加载数据
|
|
|
- self.skuCollectionView.reloadData()
|
|
|
- //更新collectionView的高度约束
|
|
|
- let contentSize = self.skuCollectionView.collectionViewLayout.collectionViewContentSize
|
|
|
- skuCollectionView.snp.remakeConstraints { (make) in
|
|
|
- make.height.equalTo(contentSize.height)
|
|
|
- make.top.equalToSuperview()
|
|
|
- make.right.equalTo(goImageView.snp.left).offset(-10)
|
|
|
- make.left.equalTo(selectedLabel.snp.right).offset(20)
|
|
|
- make.bottom.equalTo(bgView)
|
|
|
- }
|
|
|
- self.skuCollectionView.collectionViewLayout.invalidateLayout()
|
|
|
-
|
|
|
//collectionView重新加载数据
|
|
|
self.iconCollectionView.reloadData()
|
|
|
//更新collectionView的高度约束
|
|
@@ -236,22 +194,12 @@ extension ProductDetailProductSkuTableViewCell: UICollectionViewDelegateFlowLayo
|
|
|
}
|
|
|
|
|
|
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
|
|
- if collectionView == skuCollectionView {
|
|
|
- return 3
|
|
|
- }else {
|
|
|
- return 4
|
|
|
- }
|
|
|
+ return 4
|
|
|
}
|
|
|
|
|
|
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
|
|
-
|
|
|
- if collectionView == skuCollectionView {
|
|
|
- let cell = ProductDetailProductSkuLabelCollectionViewCell.cellWith(collectionView: collectionView, indexPath: indexPath)
|
|
|
- return cell
|
|
|
- }else {
|
|
|
let cell = ProductDetailProductSkuIconCollectionViewCell.cellWith(collectionView: collectionView, indexPath: indexPath)
|
|
|
return cell
|
|
|
- }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -260,19 +208,10 @@ extension ProductDetailProductSkuTableViewCell: UICollectionViewDelegateFlowLayo
|
|
|
}
|
|
|
|
|
|
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
|
|
|
- if collectionView == skuCollectionView {
|
|
|
- return 5
|
|
|
- }else {
|
|
|
- return 0
|
|
|
- }
|
|
|
-
|
|
|
+ return 0
|
|
|
}
|
|
|
|
|
|
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
|
|
|
- if collectionView == skuCollectionView {
|
|
|
- return 5
|
|
|
- }else {
|
|
|
- return 0
|
|
|
- }
|
|
|
+ return 0
|
|
|
}
|
|
|
}
|