From d9a2bbdb9595037432c36766489110c4b9229ac0 Mon Sep 17 00:00:00 2001
From: 杨锴 <841720330@qq.com>
Date: 星期一, 19 八月 2024 16:32:04 +0800
Subject: [PATCH] fix

---
 XQMuse/Root/Course/CCell/CourseOfficalCommendTopCCell.swift |   51 +++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/XQMuse/Root/Course/CCell/CourseOfficalCommendTopCCell.swift b/XQMuse/Root/Course/CCell/CourseOfficalCommendTopCCell.swift
index 1595704..c55f467 100644
--- a/XQMuse/Root/Course/CCell/CourseOfficalCommendTopCCell.swift
+++ b/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
+				}
 }

--
Gitblit v1.7.1