fix
杨锴
2024-08-23 adc2db9bb29e7f316c46b6de679db1522ffc9cc8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//
//  Home_Style_4_TCell.swift
//  XQMuse
//
//  Created by 无故事王国 on 2024/8/13.
//
 
import UIKit
import JQTools
 
enum Home_Style_4_Style{
                case style1
                case style2
}
 
class Home_Style_4_TCell: UITableViewCell {
 
                var style:Home_Style_4_Style!
                
                @IBOutlet weak var collectionView: UICollectionView!
 
                override func awakeFromNib() {
        super.awakeFromNib()
                                collectionView.delegate = self
                                collectionView.dataSource = self
                                collectionView.isPagingEnabled = true
                                collectionView.register(UINib(nibName: "Home_Style_4_Inner_1_CCell", bundle: nil), forCellWithReuseIdentifier: "_Home_Style_4_Inner_1_CCell")
                                collectionView.register(UINib(nibName: "Home_Style_4_Inner_CCell", bundle: nil), forCellWithReuseIdentifier: "_Home_Style_4_Inner_CCell")
                                collectionView.showsHorizontalScrollIndicator = false
    }
}
 
extension Home_Style_4_TCell:UICollectionViewDelegate & UICollectionViewDataSource{
 
                func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
                                let detailVC = HomeItemDetailVC()
                                JQ_currentViewController().jq_push(vc: detailVC)
                }
 
                func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
                                return 3
                }
                
                func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
                                if style == .style1{
                                                let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_Home_Style_4_Inner_1_CCell", for: indexPath) as! Home_Style_4_Inner_1_CCell
                                                return cell
                                }
 
                                if style == .style2{
                                                let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_Home_Style_4_Inner_CCell", for: indexPath) as! Home_Style_4_Inner_CCell
                                                return cell
                                }
 
                                return UICollectionViewCell()
                }
}
 
extension Home_Style_4_TCell:UICollectionViewDelegateFlowLayout{
                func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
                                return 0
                }
                func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
                                return 0
                }
 
                func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
                                if style == .style2{
                                                return CGSize(width: JQ_ScreenW, height: JQ_ScreenW * 0.734)
                                }
 
                                if style == .style1{
                                                return CGSize(width: JQ_ScreenW, height: JQ_ScreenW * 0.551)
                                }
 
                                return .zero
                }
}