CNLivePlayerFastForwardPreviewView.swift
2.4 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
//
// CNLivePlayerFastForwardPreviewView.swift
// metaCode
//
// Created by zx on 2023/11/27.
//
import Foundation
class CNLivePlayerFastForwardPreviewView:UIView{
//快进进度0~1
var _value:CGFloat = 0
var value:CGFloat{
get{
_value
}
set{
_value = newValue
if (_value > 1) {
_value = 1
}else if (_value < 0) {
_value = 0
}
var progressViewFrame = self.progressView!.frame
progressViewFrame.size.width = self.totalView!.frame.size.width*_value
self.progressView?.frame = progressViewFrame
}
}
//时间
var _time:String?
var time:String?{
get{
_time
}
set{
_time = newValue
self.timeLab?.text = _time
}
}
//时间文本
var timeLab:UILabel?
var totalView:UIView?
var progressView:UIView?
init() {
super.init(frame: CGRectZero)
self.backgroundColor = UIColor(white: 0, alpha: 0.6)
self.initUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func layoutSubviews() {
super.layoutSubviews()
self.timeLab?.frame = CGRect(x: 5, y: 0, width: self.width-5*2, height: 20)
self.timeLab?.top = (self.height-self.timeLab!.height-10-2)/2
self.totalView?.frame = CGRect(x: (self.width-120)/2, y: self.timeLab!.bottom+10, width: 120, height: 2)
self.progressView?.frame = CGRect(x: self.totalView!.left, y: self.totalView!.top, width: self.totalView!.width*self.value, height: self.totalView!.height)
}
// MARK: - initUI
func initUI(){
self.timeLab = UILabel()
self.timeLab?.textAlignment = .center
self.timeLab?.font = Font_14
self.timeLab?.textColor = .white
self.addSubview(self.timeLab!)
self.totalView = UIView()
self.totalView?.backgroundColor = UIColor(white: 1, alpha: 0.2)
self.totalView?.clipsToBounds = true
self.totalView?.layer.cornerRadius = 1
self.addSubview(self.totalView!)
self.progressView = UIView()
self.progressView?.backgroundColor = .white
self.progressView?.clipsToBounds = true
self.progressView?.layer.cornerRadius = 1
self.addSubview(self.progressView!)
}
}