CNLiveShopCouponCreateBottomView.swift
2.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
//
// CNLiveShopCouponCreateBottomView.swift
// metaCode
//
// Created by zx on 2023/12/12.
//
import Foundation
import SnapKit
protocol CNLiveShopCouponButtonClickDelegate:NSObjectProtocol{
/// 单点
/// @param gestureView 手势视图
/// @param recognizer 手势
func selectedItemButton(section:Int)
}
class CNLiveShopCouponCreateBottomView:UIView{
/// 代理
weak var delegate:CNLiveShopCouponButtonClickDelegate?
lazy var cancelsBtn: UIButton = {
let button = UIButton(type: .custom)
button.backgroundColor = UIColor.white
button.setTitleColor( HexColor("#3A3A3A"), for: .normal)
button.setTitle("取消", for: .normal)
button.tag = 1000
button.addTarget(self, action: #selector(selectAction), for: .touchUpInside)
return button
}()
lazy var saveBtn: UIButton = {
let saveBtn = UIButton(type: .custom)
saveBtn.tag = 1001
let gradientLayer = CAGradientLayer()
gradientLayer.locations = [0, 1]
gradientLayer.startPoint = CGPoint(x: 0.88, y: 0.11)
gradientLayer.endPoint = CGPoint(x: 0.28, y: 0.81)
let color1 = HexColor("#7ED785")!.cgColor
let color2 = HexColor("#64C367")!.cgColor
gradientLayer.colors = [color1, color2]
gradientLayer.frame = CGRect(x: 0, y: 0, width: 245, height: 50)
saveBtn.layer.addSublayer(gradientLayer)
saveBtn.setTitle("保存", for: .normal)
saveBtn.setTitleColor(.white, for: .normal)
saveBtn.addTarget(self, action: #selector(selectAction), for: .touchUpInside)
return saveBtn
}()
override init(frame: CGRect) {
super.init(frame: frame)
self.addSubview(self.cancelsBtn)
self.addSubview(self.saveBtn)
self.saveBtn.snp.makeConstraints { make in
make.top.right.bottom.equalTo(self)
make.width.equalTo(245)
}
self.cancelsBtn.snp.makeConstraints { make in
make.left.top.bottom.equalTo(self)
make.right.equalTo(self.saveBtn.snp.left)
}
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
@objc func selectAction(_ sender: UIButton) {
self.delegate?.selectedItemButton(section: sender.tag - 1000)
}
}