fix
杨锴
2024-08-19 d9a2bbdb9595037432c36766489110c4b9229ac0
XQMuse/Root/Course/CCell/CourseOfficalCommendTopCCell.swift
@@ -6,12 +6,59 @@
//
import UIKit
import JQTools
class CourseOfficalCommendTopCCell: UICollectionViewCell {
    override func awakeFromNib() {
            @IBOutlet weak var view_bannerContentView: UIView!
            @IBOutlet weak var collectionView: UICollectionView!
            private var titleItems = [TitleItem]()
            private var clouse:((Int)->Void)?
            override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
                        collectionView.delegate = self
                        collectionView.dataSource = self
                        collectionView.isScrollEnabled = false
                        collectionView.register(UINib(nibName: "CourseOfficialItemCCell", bundle: nil), forCellWithReuseIdentifier: "_CourseOfficialItemCCell")
    }
            func setTitles(_ items:[TitleItem]){
                        titleItems = items
                        collectionView.reloadData()
            }
            func clickAtClouse(_ clouse:@escaping (Int)->Void){
                        self.clouse = clouse
            }
}
extension CourseOfficalCommendTopCCell:UICollectionViewDelegate & UICollectionViewDataSource{
            func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
                        return titleItems.count
            }
            func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
                        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_CourseOfficialItemCCell", for: indexPath) as! CourseOfficialItemCCell
                        cell.setItem(titleItems[indexPath.row])
                        return cell
            }
            func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
                        clouse?(indexPath.row)
            }
}
extension CourseOfficalCommendTopCCell:UICollectionViewDelegateFlowLayout{
            func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
                        let w = JQ_ScreenW / 4
                        return CGSize(width: w, height: 101.25)
            }
            func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
                        return 5
            }
            func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
                        return 0
            }
}