CNLivePlayerFailureView.swift
3.21 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
//
// CNLivePlayerFailureView.swift
// metaCode
//
// Created by zx on 2023/11/24.
//
import Foundation
//点击刷新回调
typealias clickRefreshCallBackBlock = () -> Void
//点击返回回调
typealias clickBackCallBackBlock = () -> Void
class CNLivePlayerFailureView:UIView{
// MARK: - 属性
//失败原因
var _errorMessage:String?
var errorMessage:String?{
get{
_errorMessage
}
set{
_errorMessage = newValue
self.titleLab?.text = _errorMessage
}
}
// MARK: - 回调
//点击刷新回调
var clickRefreshCallBack:clickRefreshCallBackBlock?
//点击返回回调
var clickBackCallBack:clickBackCallBackBlock?
//返回按钮
var backBtn:UIButton?
//返回按钮图片
var backImageView:UIImageView?//DSImageView
var titleLab:UILabel?
var refreshBtn:UIButton?
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
init() {
super.init(frame: CGRectZero)
self.backgroundColor = .black
self.initUI()
}
override func layoutSubviews() {
super.layoutSubviews()
self.backBtn?.frame = CGRect(x: 0, y: KStatusBarHeight, width: KNavigationHeight-KStatusBarHeight, height: KNavigationHeight-KStatusBarHeight)
self.backImageView?.frame = CGRect(x: (self.backBtn!.width - 22)*0.5, y: (self.backBtn!.height - 22)*0.5, width: 22, height: 22)
self.titleLab?.frame = CGRect(x: 5, y: 0, width: self.width - 5*2, height: 20)
self.refreshBtn?.frame = CGRect(x: (self.width-70)*0.5, y: 0, width: 80, height: 32)
self.titleLab?.top = (self.height - (self.titleLab!.height+12+self.refreshBtn!.height))*0.5
self.refreshBtn?.top = self.titleLab!.bottom + 12
}
// MARK: - initUI
func initUI(){
self.backBtn = UIButton(type: .custom)
self.backBtn?.addTarget(self, action: #selector(backBtnClick), for: .touchUpInside)
self.addSubview(self.backBtn!)
self.backImageView = UIImageView()
self.backImageView?.clipsToBounds = true
self.backImageView?.contentMode = .scaleAspectFit
self.backImageView?.image = UIImage(named: "DS_player_nav_back")
self.backBtn?.addSubview(self.backImageView!)
self.titleLab = UILabel()
self.titleLab?.textAlignment = .center
self.titleLab?.font = Font_14
self.titleLab?.textColor = .white
self.addSubview(self.titleLab!)
self.refreshBtn = UIButton(type: .custom)
self.refreshBtn?.layer.cornerRadius = 32/2
self.refreshBtn?.clipsToBounds = true
self.refreshBtn?.setTitle("刷新重试", for: .normal)
self.refreshBtn?.setTitleColor(.white, for: .normal)
self.refreshBtn?.backgroundColor = HexColor("#ff725c")
self.refreshBtn?.titleLabel?.font = Font_13
self.refreshBtn?.addTarget(self, action: #selector(refreshBtnClick), for: .touchUpInside)
self.addSubview(self.refreshBtn!)
}
// MARK: - 触发事件
@objc func refreshBtnClick(){
self.clickRefreshCallBack!()
}
@objc func backBtnClick(){
self.clickBackCallBack!()
}
}