CNLiveShopClassilyManageHeaderView.swift
5.82 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
131
132
133
134
135
136
137
138
//
// CNLiveShopClassilyManageHeaderView.swift
// metaCode
//
// Created by zx on 2023/12/12.
//
import Foundation
class CNLiveShopClassilyManageHeaderView:UIView{
/// 分类model
var _classifyModel:CNLiveShopClassifyListModel?
var classifyModel:CNLiveShopClassifyListModel?{
get{
_classifyModel
}
set{
_classifyModel = newValue
let oneLevelNumberAtt = NSMutableAttributedString(string: "\(_classifyModel!.cate1 ?? "")\n一级分类")
oneLevelNumberAtt.addAttribute(.font, value: UIFont.systemFont(ofSize: 19), range: NSMakeRange(0, _classifyModel!.cate1!.count))
oneLevelNumberAtt.addAttribute(.foregroundColor, value: HexColor("#333333")!, range: NSMakeRange(0, classifyModel!.cate1!.count))
self.oneLevelClassifyLab.attributedText = oneLevelNumberAtt
let twoLevelNumberAtt = NSMutableAttributedString(string: "\(_classifyModel!.cate2 ?? "")\n二级分类")
twoLevelNumberAtt.addAttribute(.font, value: UIFont.systemFont(ofSize: 19), range: NSMakeRange(0, _classifyModel!.cate2!.count))
twoLevelNumberAtt.addAttribute(.foregroundColor, value: HexColor("#333333")!, range: NSMakeRange(0, classifyModel!.cate2!.count))
self.twoLevelClassifyLab.attributedText = twoLevelNumberAtt
let goodsNumberAtt = NSMutableAttributedString(string: "\(_classifyModel!.goods ?? "")\n商品数量")
goodsNumberAtt.addAttribute(.font, value: UIFont.systemFont(ofSize: 19), range: NSMakeRange(0, _classifyModel!.goods!.count))
goodsNumberAtt.addAttribute(.foregroundColor, value: HexColor("#333333")!, range: NSMakeRange(0, classifyModel!.goods!.count))
self.goodsNumberLab.attributedText = goodsNumberAtt
}
}
// MARK: - Lazy
lazy var contentView :UIView = {
let contentView = UIView(frame: CGRect(x: 0, y: 0, width: KSreenWidth, height: 74))
contentView.backgroundColor = .white
return contentView
}()
///一级分类
lazy var oneLevelClassifyLab: UILabel = {
let oneLevelClassifyLab = UILabel.init(frame: CGRectMake(0, 0, KSreenWidth/3, self.contentView.height))
oneLevelClassifyLab.numberOfLines = 0
oneLevelClassifyLab.textColor = HexColor("#999999")
oneLevelClassifyLab.textAlignment = .center
oneLevelClassifyLab.font = Font_10
oneLevelClassifyLab.text = "0\n一级分类"
return oneLevelClassifyLab
}()
///分割线1
lazy var line1: UILabel = {
let line1 = UILabel.init(frame: CGRectMake(self.oneLevelClassifyLab.right, 24, 1, 25))
line1.backgroundColor = HexColor("#E6E6E6")
return line1
}()
///二级分类
lazy var twoLevelClassifyLab: UILabel = {
let twoLevelClassifyLab = UILabel.init(frame: CGRectMake(self.oneLevelClassifyLab.right, 0, KSreenWidth/3, self.contentView.height))
twoLevelClassifyLab.numberOfLines = 0
twoLevelClassifyLab.textColor = HexColor("#999999")
twoLevelClassifyLab.textAlignment = .center
twoLevelClassifyLab.font = Font_10
twoLevelClassifyLab.text = "0\n二级分类"
return twoLevelClassifyLab
}()
///分割线2
lazy var line2: UILabel = {
let line2 = UILabel.init(frame: CGRectMake(self.twoLevelClassifyLab.right, 24, 1, 25))
line2.backgroundColor = HexColor("#E6E6E6")
return line2
}()
///商品数量
lazy var goodsNumberLab: UILabel = {
let goodsNumberLab = UILabel.init(frame: CGRectMake(self.twoLevelClassifyLab.right, 0, KSreenWidth/3, self.contentView.height))
goodsNumberLab.numberOfLines = 0
goodsNumberLab.textColor = HexColor("#999999")
goodsNumberLab.textAlignment = .center
goodsNumberLab.font = Font_10
goodsNumberLab.text = "0\n商品数量"
return goodsNumberLab
}()
override init(frame: CGRect) {
super.init(frame: frame)
self.initUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
// MARK: - 初始化UI
func initUI(){
self.addSubview(self.contentView)
self.contentView.addSubview(self.oneLevelClassifyLab)
self.contentView.addSubview(self.line1)
self.contentView.addSubview(self.twoLevelClassifyLab)
self.contentView.addSubview(self.line2)
self.contentView.addSubview(self.goodsNumberLab)
//分类名称
let classifyNameLab = UILabel(frame: CGRect(x: 0, y: self.contentView.bottom, width: KSreenWidth*0.3, height: 40))
classifyNameLab.text = "分类名称"
classifyNameLab.textColor = HexColor("#999999")
classifyNameLab.font = Font_14
classifyNameLab.textAlignment = .center
self.addSubview(classifyNameLab)
//排序
let sortLab = UILabel(frame: CGRect(x: classifyNameLab.right, y: self.contentView.bottom, width: KSreenWidth*0.2, height: 40))
sortLab.text = "排序"
sortLab.textColor = HexColor("#999999")
sortLab.font = Font_14
sortLab.textAlignment = .center
self.addSubview(sortLab)
//是否显示
let hideLab = UILabel(frame: CGRect(x: sortLab.right, y: self.contentView.bottom, width: KSreenWidth*0.2, height: 40))
hideLab.text = "是否显示"
hideLab.textColor = HexColor("#999999")
hideLab.font = Font_14
hideLab.textAlignment = .center
self.addSubview(hideLab)
//操作
let handelLab = UILabel(frame: CGRect(x: hideLab.right, y: self.contentView.bottom, width: KSreenWidth*0.3, height: 40))
handelLab.text = "操作"
handelLab.textColor = HexColor("#999999")
handelLab.font = Font_14
handelLab.textAlignment = .center
self.addSubview(handelLab)
}
}