CNLivePlayletHomePageController.swift
2.64 KB
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
//
// 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
}
}
}