CNLivePlayletHomePageController.swift 2.64 KB
//
//  CNLivePlayletHomePageController.swift
//  metaCode
//
//  Created by zx on 2024/1/4.
//  短剧主页

import Foundation

class CNLivePlayletHomePageController:CNLiveBaseViewController, UITableViewDataSource, UITableViewDelegate{
    
    let kCNLivePlayletCellIdentifier = "kCNLivePlayletCellIdentifier"
    let kCNLivePlayletHeaderCellIdentifier = "kCNLivePlayletHeaderCellIdentifier"

    // MARK: - 懒加载
    ///数据源
    lazy var dataArray: NSMutableArray = {
        var dataArray = NSMutableArray()
        return dataArray
    }()
    lazy var tableView : UITableView = {
        let tableView = UITableView(frame: .zero, style: .plain)
        tableView.dataSource = self
        tableView.delegate = self
        tableView.separatorStyle = .none
        tableView.tableFooterView = UIView.init()
        tableView.register(CNLivePlayletHomePageCell.self, forCellReuseIdentifier: kCNLivePlayletCellIdentifier)
        tableView.register(CNLivePlayletHomePageHeaderCell.self, forCellReuseIdentifier: kCNLivePlayletHeaderCellIdentifier)
        return tableView
    }()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.setUI()
    }
    func setUI(){
        navigationBarHidden = false
        self.view.addSubview(self.tableView)
        self.tableView.frame = CGRect(x: 0, y: KNavigationHeight, width: KSreenWidth, height: KSreenHeight-KNavigationHeight)
    }
    func numberOfSections(in tableView: UITableView) -> Int {
        2
    }
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        if section == 0{
            return 1
        }
        return 30 //self.dataArray.count
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        
        if indexPath.section == 0{
            guard let cell = tableView.dequeueReusableCell(withIdentifier: kCNLivePlayletHeaderCellIdentifier) as? CNLivePlayletHomePageHeaderCell
            else {
                let cell = CNLivePlayletHomePageHeaderCell()
                return cell
            }

            return cell
        }else{
            guard let cell = tableView.dequeueReusableCell(withIdentifier: kCNLivePlayletCellIdentifier) as? CNLivePlayletHomePageCell
            else {
                let cell = CNLivePlayletHomePageCell()
                return cell
            }
            cell.iconImgView.backgroundColor = .red
            return cell
        }
    }
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        if indexPath.section == 0{
            return 300
        }else{
            return 100
        }
    }
}