CNLiveHomePageDuanJuCell.swift
4.63 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
//
// CNLiveHomePageDuanJuCell.swift
// metaCode
//
// Created by zx on 2024/1/8.
// 首页-在追短剧cell
import Foundation
import QMUIKit
typealias DuanJUCellSelectedCallBackBlock = (_ cell: CNLiveHomePageDuanJuCell) -> Void
class CNLiveHomePageDuanJuCell:UITableViewCell,UITableViewDelegate,UITableViewDataSource{
let kCNLiveAlbumCellIdentifier = "kCNLiveAlbumCellIdentifier"
// let bgBackView = UIView()
var DuanJUCellSelectedCallBack:DuanJUCellSelectedCallBackBlock?
lazy var modelArr: NSMutableArray = {
var dataArray = NSMutableArray()
return dataArray
}()
func setModelArr(modelArr:NSMutableArray){
self.modelArr = NSMutableArray(array: modelArr)
self.tableView.height = CGFloat(self.modelArr.count)*(45+15*2)
self.totalView.height = CGFloat(self.modelArr.count)*(45+15*2) + 55
self.tableView.reloadData()
// //定义view的阴影颜色
// self.totalView.layer.shadowColor = UIColor.black.cgColor
// //阴影偏移量
// self.totalView.layer.shadowOffset=CGSize(width:1, height:1)
// //定义view的阴影宽度,模糊计算的半径
// self.totalView.layer.shadowRadius = 12
// //定义view的阴影透明度,注意:如果view没有设置背景色阴影也是不会显示的
// self.totalView.layer.shadowOpacity = 0.4
}
//MARK: - 懒加载
///区块标题
lazy var blockTitleLabl: UILabel = {
let titleLbl = UILabel(frame: CGRect(x: DownSlideRecommendLeftGap, y: DownSlideRecommendLeftGap+5, width: DownSlideSingleCourseW-DownSlideRecommendLeftGap*2, height: 30))
titleLbl.text = "在追短剧"
titleLbl.font = BoldFont_21
titleLbl.textColor = HexColor("#333333")
return titleLbl
}()
lazy var totalView : UIView = {
let totalView = UIView(frame: CGRect(x: 15, y: 15, width: KSreenWidth-30, height: 100))
return totalView
}()
lazy var tableView : UITableView = {
let tableView = UITableView(frame: CGRect(x: 0, y: self.blockTitleLabl.bottom+5, width: KSreenWidth-30, height: 50), style: .plain)
tableView.dataSource = self
tableView.delegate = self
tableView.separatorStyle = .none
tableView.tableFooterView = UIView.init()
tableView.backgroundColor = .clear
tableView.register(CNLiveAlbumCell.self, forCellReuseIdentifier: kCNLiveAlbumCellIdentifier)
return tableView
}()
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
self.selectionStyle = .none
self.contentView.addSubview(self.totalView)
self.totalView.addSubview(self.blockTitleLabl)
self.totalView.addSubview(self.tableView)
self.tableView.backgroundColor = .white
self.totalView.layer.cornerRadius = 12
self.totalView.clipsToBounds = true
self.totalView.backgroundColor = .white
//定义view的阴影颜色
self.totalView.layer.shadowColor = UIColor.black.cgColor
//阴影偏移量
self.totalView.layer.shadowOffset=CGSize(width:1, height:1)
//定义view的阴影宽度,模糊计算的半径
self.totalView.layer.shadowRadius = 12
//定义view的阴影透明度,注意:如果view没有设置背景色阴影也是不会显示的
self.totalView.layer.shadowOpacity = 0.4
setupUI()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
private func setupUI() {
contentView.backgroundColor = HexColor(kCNDownSlideBackgroundColorHex)
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
self.modelArr.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let model = self.modelArr[indexPath.row] as! CNLiveAlbumMsgModel
guard let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveAlbumCellIdentifier) as? CNLiveAlbumCell
else {
let cell = CNLiveAlbumCell()
return cell
}
cell.albumMsgModel = model
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
self.DuanJUCellSelectedCallBack!(self)
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 45+15*2
}
//MARK: - 事件
@objc func playBtnAction(){
showLoading(message: "")
// self.getAlbumList()
}
}