CNLiveDownSlideRealHotListCell.swift
3.05 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
//
// CNLiveDownSlideRealHotListCell.swift
// metaCode
//
// Created by zx on 2024/5/11.
// 实时热榜里的 水平列表cell
import Foundation
import Kingfisher
class CNLiveDownSlideRealHotListCell: UICollectionViewCell {
//是前三
var num = 0//第几
//contentsModel
var _contentsModel : CNLiveDownSlideContentsModel?
var contentsModel : CNLiveDownSlideContentsModel? {
get{
_contentsModel
}
set{
_contentsModel = newValue!
setupNewUI(model: _contentsModel!)
}
}
lazy var iconImgView :UIImageView = {
let iconImgView = UIImageView(frame: CGRect(x: 0, y: 0, width: 69, height: 100))
iconImgView.contentMode = .scaleAspectFill
iconImgView.clipsToBounds = true
return iconImgView
}()
lazy var titleLabel: UILabel = {
let titleLabel = UILabel.init(frame: CGRectMake(0, self.iconImgView.bottom+5, self.iconImgView.width, 19))
titleLabel.textColor = HexColor("#333333")
titleLabel.textAlignment = .left
titleLabel.font = BoldFont_13
return titleLabel
}()
//第一第二第三角标
lazy var firstIconView :UIImageView = {
let layerView = UIImageView()
layerView.frame = CGRect(x: 5, y: 0, width: 20, height: 17)
return layerView
}()
lazy var numTitleLabel: UILabel = {
let titleLabel = UILabel(frame: self.firstIconView.bounds)
titleLabel.textAlignment = .center
titleLabel.text = "1"
titleLabel.font = Font_12
return titleLabel
}()
override init(frame: CGRect) {
super.init(frame: frame)
self.contentView.addSubview(self.iconImgView)
self.contentView.addSubview(self.titleLabel)
self.contentView.addSubview(self.firstIconView)
self.firstIconView.addSubview(self.numTitleLabel)
self.firstIconView.isHidden = true
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setupNewUI(model:CNLiveDownSlideContentsModel){
self.iconImgView.kf.setImage(with: URL(string:model.poster))
self.titleLabel.text = model.title
if self.num == 1{
self.firstIconView.isHidden = false
self.firstIconView.backgroundColor = HexColor("#F23A87")
self.numTitleLabel.text = "1"
// self.firstIconView.image = UIImage(named: "")
}else if self.num == 2{
self.firstIconView.isHidden = false
self.firstIconView.backgroundColor = HexColor("#FB723F")
self.numTitleLabel.text = "2"
// self.firstIconView.image = UIImage(named: "")
}else if self.num == 3{
self.firstIconView.isHidden = false
self.firstIconView.backgroundColor = HexColor("#FFB03D")
self.numTitleLabel.text = "3"
// self.firstIconView.image = UIImage(named: "")
}else{
self.firstIconView.isHidden = true
self.numTitleLabel.text = ""
}
}
}