//
|
// CourseOnlineListVC.swift
|
// WanPai
|
//
|
// Created by 无故事王国 on 2023/6/15.
|
//
|
|
import UIKit
|
import JQTools
|
import MJRefresh
|
|
class CourseOnlineListVC: BaseVC {
|
|
lazy var searchView:CourseOnlineSearchView = {
|
let searchV = CourseOnlineSearchView.jq_loadNibView()
|
searchV.frame = CGRect(x: 0, y: JQ_NavBarHeight, width: JQ_ScreenW, height: JQ_ScreenW * 0.564 + 57)
|
searchV.alpha = 1
|
return searchV
|
}()
|
|
var collectionView:UICollectionView!
|
|
override func viewDidLoad() {
|
super.viewDidLoad()
|
}
|
|
override func setUI() {
|
let flowlayout = OnlineLayout()
|
|
flowlayout.itemSize = CGSize(width: (JQ_ScreenW - 50) / 2, height: 195)
|
flowlayout.minimumLineSpacing = 22
|
flowlayout.minimumLineSpacing = 22
|
// flowlayout.sectionHeadersPinToVisibleBounds = true
|
flowlayout.headerReferenceSize = CGSize(width: JQ_ScreenW, height: 52)
|
collectionView = UICollectionView(frame: .zero, collectionViewLayout: flowlayout)
|
collectionView.register(UINib(nibName: "CourseOnlineCCell", bundle: nil), forCellWithReuseIdentifier: "_CourseOnlineCCell")
|
collectionView.register(UINib(nibName: "CourseOnlineHeadView", bundle: nil), forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: "_CourseOnlineHeadView")
|
collectionView.delegate = self
|
collectionView.dataSource = self
|
|
let insertH = JQ_ScreenW * 0.564 + 57
|
collectionView.contentInset = UIEdgeInsets(top: insertH, left: 14, bottom: 14, right: 14)
|
collectionView.scrollIndicatorInsets = UIEdgeInsets(top: insertH, left: 0, bottom: 0, right: 0)
|
|
view.addSubview(collectionView)
|
collectionView.snp.makeConstraints { make in
|
make.edges.equalToSuperview()
|
}
|
|
view.addSubview(searchView)
|
|
}
|
|
func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
let insertH = scrollView.contentOffset.y + JQ_ScreenW * 0.5641 + 57
|
searchView.jq_y = -insertH
|
}
|
}
|
|
extension CourseOnlineListVC:UICollectionViewDelegate{
|
|
}
|
|
extension CourseOnlineListVC:UICollectionViewDataSource{
|
func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
|
|
if kind == UICollectionView.elementKindSectionHeader{
|
let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "_CourseOnlineHeadView", for: indexPath) as! CourseOnlineHeadView
|
headerView.indexPath = indexPath
|
headerView.moreClouse = { [weak self] index in
|
let vc = CourseOnlineSubListVC()
|
vc.title = self?.title ?? ""
|
self?.push(vc: vc)
|
}
|
return headerView
|
}
|
|
return UICollectionReusableView()
|
}
|
|
|
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_CourseOnlineCCell", for: indexPath) as! CourseOnlineCCell
|
return cell
|
}
|
|
func numberOfSections(in collectionView: UICollectionView) -> Int {
|
return 3
|
}
|
|
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
return 4
|
}
|
}
|
|
class OnlineLayout:UICollectionViewFlowLayout{
|
|
}
|