Prechádzať zdrojové kódy

时间条 UI 调整新设计

jsonwang 3 rokov pred
rodič
commit
fb95ef64e7

+ 46 - 36
BFFramework/Classes/Stuckpoint/View/PQStuckPointCuttingView.swift

@@ -38,7 +38,7 @@ class PQStuckPointCuttingView: UIView {
     /// 时间间隔
     private var timeRange: CGFloat = cDefaultMargin
     /// 刻度高
-    private var rateHeight: CGFloat = cDefaultMargin * 5
+    private var rateHeight: CGFloat = 23
     /// 时间线宽
     private var timeLineWidth: CGFloat = 35
     /// 时间线间隔
@@ -50,7 +50,7 @@ class PQStuckPointCuttingView: UIView {
     /// 频率间隔
     private var frequencyMargin: CGFloat = 4
     /// 左右间隔
-    private var margin: CGFloat = cDefaultMargin * 3
+    private var margin: CGFloat = 2
     /// 每秒宽度
     private var perSecondWidth: CGFloat = 0
     /// 滑动区域大小
@@ -73,42 +73,36 @@ class PQStuckPointCuttingView: UIView {
         } else {
 //            automaticallyAdjustsScrollViewInsets = false
         }
+        scrollView.backgroundColor = .clear
         return scrollView
     }()
 
+    //
     lazy var rateView: UIView = {
-        let rateView = UIView(frame: CGRect(x: 0, y: videoCropView.frame.minY + 16.5, width: scrollView.contentSize.width, height: rateHeight))
-        rateView.backgroundColor = PQBFConfig.shared.otherTintColor
+        let rateView = UIView(frame: CGRect(x: 0, y: 22, width: scrollView.contentSize.width, height: rateHeight))
+        rateView.backgroundColor = .clear
         return rateView
     }()
+    
+    //总时长
+    lazy var tatalTimeLabel:UILabel = {
+        let tatalTimeLabel = UILabel()
+        tatalTimeLabel.font = UIFont.systemFont(ofSize: 11)
+        tatalTimeLabel.textAlignment = .right
+        tatalTimeLabel.textColor = UIColor.hexColor(hexadecimal: PQBFConfig.shared.styleColor.rawValue)
+        tatalTimeLabel.text = "\(Float64(stuckPointEndTime - stuckPointStartTime).formatDurationToHMS())"
+       return tatalTimeLabel
+    }()
 
-    lazy var videoCropView: PQVideoCutingOprateView = {
-        var originX: CGFloat = perSecondWidth * (stuckPointStartTime + cutStartTime) + margin
-        if contentWidth > scrollView.frame.width {
-            originX = perSecondWidth * (stuckPointStartTime - cutStartTime) + margin
-        }
-        let videoCropView: PQVideoCutingOprateView = PQVideoCutingOprateView(frame: CGRect(x: margin, y: frame.height - 90, width: contentWidth - margin * 2, height: 90), duration: videoDuration, startTime: cutStartTime, endTime: cutEndTime, minDuration: minCutTime, maxDuration: maxCutTime)
-        videoCropView.cutRangeDidChanged = { [weak self] cutStartTime, cutEndTime, _ in
-            self?.cutStartTime = cutStartTime
-            self?.cutEndTime = cutEndTime
-            self?.videoProgress = 0
-            // 计算当前时间
-            if self?.videoRangeDidChanged != nil {
-                self?.videoRangeDidChanged!(cutStartTime, cutEndTime)
-            }
-        }
-        videoCropView.progressDidChanged = { [weak self] progress in
-            self?.videoProgress = progress
-            if self?.videoProgressDidChanged != nil {
-                self?.videoProgressDidChanged!(progress)
-            }
-        }
-        videoCropView.didEndDragging = { [weak self] type, startTime, endTime, progress in
-            self?.videoProgress = 0
-            if self?.videoDidEndDragging != nil {
-                self?.videoDidEndDragging!(type, startTime, endTime, progress)
-            }
-        }
+    //显示选择框
+    lazy var videoCropView: UIView = {
+        var cropViewWidth: CGFloat = perSecondWidth * (stuckPointEndTime - stuckPointStartTime) + margin
+        let videoCropView:UIView = UIView.init(frame:  CGRect(x:     (cScreenWidth - cropViewWidth) / 2 , y: 0, width: cropViewWidth, height: 80))
+        videoCropView.isUserInteractionEnabled = false
+        videoCropView.layer.borderColor = UIColor.hexColor(hexadecimal: PQBFConfig.shared.styleColor.rawValue).cgColor
+        videoCropView.layer.borderWidth = 2
+        videoCropView.layer.cornerRadius = 8
+ 
         return videoCropView
     }()
 
@@ -126,6 +120,7 @@ class PQStuckPointCuttingView: UIView {
         if videoDuration < maxCutTime {
             maxCutTime = videoDuration
         }
+        backgroundColor = .red
         // 更新卡点值
         updateEndTime(startTime: startTime, endTime: endTime)
     }
@@ -146,8 +141,22 @@ class PQStuckPointCuttingView: UIView {
         }
         backgroundColor = PQBFConfig.shared.styleBackGroundColor
         addSubview(scrollView)
+       
         addData()
+        
+        //计算完第一秒相素宽度再添加裁剪view
+        addSubview(videoCropView)
+        videoCropView.addSubview(tatalTimeLabel)
+        
+        tatalTimeLabel.snp.remakeConstraints { make in
+            make.width.equalTo(40)
+            make.height.equalTo(15)
+            make.top.equalTo(videoCropView.snp_top).offset(6)
+            make.right.equalTo(videoCropView.snp_right).offset(-6)
+          
+        }
     }
+    
 
     func addData() {
         perSecondWidth = (timeLineWidth + timeLineMargin) / timeRange
@@ -167,12 +176,13 @@ class PQStuckPointCuttingView: UIView {
         }
         scrollView.contentSize = CGSize(width: contentWidth, height: scrollView.frame.height)
         for index in 0 ... totalCount {
-            let titleLab = UILabel(frame: CGRect(x: CGFloat(index) * (timeLineWidth + timeLineMargin) + margin, y: 0, width: timeLineWidth, height: timeHeight))
-            titleLab.font = UIFont.systemFont(ofSize: 12)
+            let titleLab = UILabel(frame: CGRect(x: CGFloat(index) * (timeLineWidth + timeLineMargin) + margin, y: rateView.frame.maxY, width: timeLineWidth, height: 30))
+            titleLab.font = UIFont.systemFont(ofSize: 11)
             titleLab.textAlignment = .center
-            titleLab.numberOfLines = 2
+            titleLab.numberOfLines = 1
+            titleLab.backgroundColor = .clear
             titleLab.textColor = UIColor.hexColor(hexadecimal: "#999999")
-            titleLab.text = "\((Float64(index) * Float64(timeRange)).formatDurationToHMS())\n·"
+            titleLab.text = "\((Float64(index) * Float64(timeRange)).formatDurationToHMS())"
             scrollView.addSubview(titleLab)
         }
         if perSecondWidth > 0, cutEndTime > 0, cutStartTime < cutEndTime {
@@ -190,7 +200,7 @@ class PQStuckPointCuttingView: UIView {
                 scrollView.contentOffset = CGPoint(x: offsetX, y: 0)
             }
             scrollView.addSubview(rateView)
-            scrollView.addSubview(videoCropView)
+          
         }
     }