CNLiveDigitalSecCollectionCell.swift
3.38 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
//
// CNLiveDigitalSecCollectionCell.swift
// metaCode
//
// Created by zx on 2024/6/18.
//
import Foundation
import Kingfisher
class CNLiveDigitalSecCollectionCell: UICollectionViewCell {
var _authListModel : MineAuthListModel?
var authListModel : MineAuthListModel? {
get{
_authListModel
}
set{
_authListModel = newValue!
setupNewUI(model: _authListModel!)
}
}
lazy var iconImgView :UIImageView = {
let iconImgView = UIImageView(frame: CGRect(x: 0, y: 0, width: 60, height: 60))
iconImgView.clipsToBounds = true
iconImgView.layer.cornerRadius = 30
iconImgView.contentMode = .scaleAspectFill
iconImgView.clipsToBounds = true
return iconImgView
}()
// lazy var rightIconImgView :UIImageView = {
// let iconImgView = UIImageView(frame: CGRect(x: self.iconImgView.width-15, y: self.iconImgView.height-15, width: 15, height: 15))
// iconImgView.image = UIImage(named: "auth_selected")
// return iconImgView
// }()
//是否选中
var _cellIsSelected : Bool = false
var cellIsSelected : Bool {
get{
_cellIsSelected
}
set{
_cellIsSelected = newValue
if _cellIsSelected == true{
//选中
self.iconImgView.layer.borderWidth = 1
self.iconImgView.layer.borderColor = HexColor("#1961FE")?.cgColor
}else{
//未选中
self.iconImgView.layer.borderWidth = 0
self.iconImgView.layer.borderColor = HexColor("#1961FE")?.cgColor
}
// self.rightIconImgView.isHidden = !_cellIsSelected
}
}
lazy var titleLabel: UILabel = {
let titleLabel = UILabel.init(frame: CGRectMake(0, self.iconImgView.bottom+8, 60, 17))
titleLabel.textColor = HexColor("#1961FE")
titleLabel.textAlignment = .center
titleLabel.adjustsFontSizeToFitWidth = true
titleLabel.font = Font_12
return titleLabel
}()
lazy var addBtn: UIButton = {
let closeBtn = UIButton(type: .custom)
closeBtn.frame = CGRect(x: 0, y: 0, width: 60, height: 60)
closeBtn.setImage(UIImage(named: "auth_add"), for: .normal)
closeBtn.addTarget(self, action: #selector(addBtnAction), for: .touchUpInside)
return closeBtn
}()
override init(frame: CGRect) {
super.init(frame: frame)
self.contentView.addSubview(self.iconImgView)
// self.iconImgView.addSubview(self.rightIconImgView)
self.contentView.addSubview(self.titleLabel)
self.contentView.addSubview(self.addBtn)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setupNewUI(model:MineAuthListModel){
if model.identityId != 0{
self.titleLabel.text = model.name
self.iconImgView.kf.setImage(with: URL(string: model.icon ?? ""))
self.addBtn.isHidden = true
self.titleLabel.isHidden = false
self.iconImgView.isHidden = false
}else{
self.addBtn.isHidden = false
self.titleLabel.isHidden = true
self.iconImgView.isHidden = true
}
}
@objc func addBtnAction(){
}
}