CNLiveVodTrailersCollectionCell.swift
4.33 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
124
125
126
127
128
129
130
//
// CNLiveVodTrailersCollectionCell.swift
// metaCode
//
// Created by zx on 2025/3/4.
//
// 点播-看点 列表cell
import Foundation
import Kingfisher
class CNLiveVodTrailersCollectionCell: UICollectionViewCell {
var num = 0//当前是第几
var isJiShuSelected = false//是否选中
//contentsModel
var _vodlistModel : CNLiveVodPlayBlockListListModel?
var vodlistModel : CNLiveVodPlayBlockListListModel? {
get{
_vodlistModel
}
set{
_vodlistModel = newValue!
setupNewUI(model: _vodlistModel!)
}
}
lazy var iconImgView :UIImageView = {
let iconImgView = UIImageView(frame: CGRect(x: 0, y: 0, width: 165, height: 93))
iconImgView.contentMode = .scaleAspectFill
iconImgView.clipsToBounds = true
iconImgView.layer.cornerRadius = 9
return iconImgView
}()
lazy var titleBgView :UIView = {
let iconImgView = UIView(frame: CGRect(x: 0, y: self.iconImgView.height, width: self.iconImgView.width, height: 76))
iconImgView.clipsToBounds = true
iconImgView.layer.cornerRadius = 10
iconImgView.layer.masksToBounds = true
// iconImgView.layer.maskedCorners = [.layerMinXMaxYCorner, .layerMaxXMaxYCorner]
iconImgView.backgroundColor = HexColor("#FAFAFA")
return iconImgView
}()
lazy var titleLabel: UILabel = {
let titleLbl = UILabel()
titleLbl.font = BoldFont_14
titleLbl.textColor = HexColor("#333333")
// titleLbl.textAlignment = .center
return titleLbl
}()
lazy var subTitleLabel: UILabel = {
let titleLbl = UILabel()
titleLbl.font = Font_12
titleLbl.textColor = HexColor("#999999")
titleLbl.numberOfLines = 2
// titleLbl.textAlignment = .center
return titleLbl
}()
//付费角标
lazy var payIconView :UIImageView = {
let layerView = UIImageView()
layerView.image = UIImage(named: "home_player_pay")
layerView.frame = CGRect(x: 0, y: 0, width: 26, height: 15)
return layerView
}()
override init(frame: CGRect) {
super.init(frame: frame)
self.contentView.addSubview(self.titleBgView)
self.titleBgView.addSubview(self.iconImgView)
self.titleBgView.addSubview(self.titleLabel)
self.titleBgView.addSubview(self.subTitleLabel)
iconImgView.snp.makeConstraints { make in
make.left.equalToSuperview()
make.top.equalToSuperview()
make.width.equalTo(165)
make.height.equalTo(93)
}
self.iconImgView.addSubview(self.payIconView)
titleBgView.snp.makeConstraints { make in
make.left.equalToSuperview()
make.top.equalTo(self.iconImgView.snp.top)
make.width.equalTo(self.iconImgView.snp.width)
make.height.equalTo(self.iconImgView.snp.height).offset(76)
}
titleLabel.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalTo(self.iconImgView.snp.bottom).offset(10)
}
subTitleLabel.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalTo(self.titleLabel.snp.bottom).offset(3)
}
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setupNewUI(model:CNLiveVodPlayBlockListListModel){
self.iconImgView.kf.setImage(with: URL(string: model.img))
self.titleLabel.text = model.title
self.subTitleLabel.text = model.subTitle
let isPaid = CNLivePlayerTool.isShowPaidIcon(product: model.product)
if isPaid{
payIconView.isHidden = false
}else{
payIconView.isHidden = true
}
if self.isJiShuSelected{
//选中
titleBgView.layer.borderColor = HexColor("#2076FF")?.cgColor
titleBgView.layer.borderWidth = 0.5
titleBgView.backgroundColor = HexColor("#EBF2FF")//nor EEEEEE,sele #EBF2FF
}else{
//未选中
titleBgView.layer.borderColor = HexColor("#EEEEEE")?.cgColor
titleBgView.layer.borderWidth = 0
titleBgView.backgroundColor = HexColor("#EEEEEE")//nor EEEEEE,sele #EBF2FF
}
}
}