CNLiveShopClassilyManageTableViewCell.swift
3.25 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
//
// CNLiveShopClassilyManageTableViewCell.swift
// metaCode
//
// Created by zx on 2023/12/12.
// 二级分类cell
import Foundation
class CNLiveShopClassilyManageTableViewCell:UITableViewCell{
///点击编辑事件回调
var editBtnBlock:editBtnActionBlock?
/// 分类model
var _classifyModel:CNLiveShopClassifyModel?
var classifyModel:CNLiveShopClassifyModel?{
get{
_classifyModel
}
set{
_classifyModel = newValue
self.classifyNameBtn.setTitle(_classifyModel!.title, for: .normal)
self.sortLab.text = _classifyModel!.ord
if Int(_classifyModel!.state ?? "") == 2{
self.showSwitch.isOn = true
}else{
self.showSwitch.isOn = false
}
}
}
///分类名称
lazy var classifyNameBtn: UIButton = {
let classifyNameBtn = UIButton(type: .custom)
classifyNameBtn.frame = CGRect(x: 0, y: 0, width: KSreenWidth*0.3, height: 50)
classifyNameBtn.setTitleColor(HexColor("#333333"), for: .normal)
classifyNameBtn.titleLabel?.font = Font_14
return classifyNameBtn
}()
///排序名称
lazy var sortLab: UILabel = {
let sortLab = UILabel.init(frame: CGRectMake(self.classifyNameBtn.right, 0, KSreenWidth*0.2, 50))
sortLab.text = "排序"
sortLab.textColor = HexColor("#333333")
sortLab.textAlignment = .center
sortLab.font = Font_14
sortLab.adjustsFontSizeToFitWidth=true
return sortLab
}()
///是否显示
lazy var showSwitch :UISwitch = {
let showSwitch = UISwitch(frame: CGRect(x: self.sortLab.right+10, y: 10, width: KSreenWidth*0.2, height: 50))
showSwitch.isEnabled = false
return showSwitch
}()
///编辑
lazy var editBtn: UIButton = {
let editBtn = UIButton(type: .custom)
editBtn.frame = CGRect(x: self.showSwitch.right, y: 0, width: KSreenWidth*0.3, height: 50)
editBtn.setTitle("编辑", for: .normal)
editBtn.setTitleColor(HexColor("#0091FF"), for: .normal)
editBtn.titleLabel?.font = Font_14
editBtn.addTarget(self, action: #selector(editBtnAction), for: .touchUpInside)
return editBtn
}()
/// 底部线
lazy var bottomLine: UILabel = {
let bottomLine = UILabel.init(frame: CGRectMake(0, 49, KSreenWidth, 1))
bottomLine.backgroundColor = HexColor("#E4E4E4")
return bottomLine
}()
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
self.initUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
// MARK: - 初始化UI
func initUI(){
self.contentView.backgroundColor = HexColor("#F6F6F6")
self.contentView.addSubview(self.classifyNameBtn)
self.contentView.addSubview(self.sortLab)
self.contentView.addSubview(self.showSwitch)
self.contentView.addSubview(self.editBtn)
self.contentView.addSubview(self.bottomLine)
}
// MARK: - response method
/// 编辑
@objc func editBtnAction(){
self.editBtnBlock!(self.classifyModel!)
}
}