Przeglądaj źródła

Merge branch 'master' of https://git.yishihui.com/iOS/BFFramework
合并分支

jsonwang 3 lat temu
rodzic
commit
38431845ee

+ 11 - 11
BFFramework/Classes/Stuckpoint/View/PQStuckPointCuttingView.swift

@@ -174,8 +174,8 @@ class PQStuckPointCuttingView: UIView {
         addSubview(leftMaskView)
         addSubview(rightMaskView)
         videoCropView.addSubview(tatalTimeLabel)
- 
         addData()
+        videoCropView.frame = CGRect(x: (cScreenWidth - cropViewWidth) / 2, y: 0, width: cropViewWidth, height: 80)
 
         tatalTimeLabel.snp.remakeConstraints { make in
             make.width.equalTo(40)
@@ -189,25 +189,27 @@ class PQStuckPointCuttingView: UIView {
 
     func addData() {
         // 1,选择区内的线个数 ,划动区域后 个数会变???
-        wavSelectCount = Int(ceil(cropViewWidth / (frequencyWidth + frequencyMargin)))
+        wavSelectCount = Int(ceil((cropViewWidth - frequencyWidth) / (frequencyWidth + frequencyMargin)) + 1)
         
-        cropViewWidth = CGFloat(wavSelectCount) * (frequencyWidth + frequencyMargin) + frequencyWidth
+        cropViewWidth = CGFloat(wavSelectCount - 1) * (frequencyWidth + frequencyMargin) + frequencyWidth
      
         // 2竖线一个间隔代表多少 S 是动态的
         oneMarginTime = (stuckPointEndTime - stuckPointStartTime) / CGFloat(wavSelectCount - 1)
         
         // 3,一共绘制的竖线个数
-        wavTotalCount = Int(ceil(videoDuration / oneMarginTime))
+        wavTotalCount = Int(ceil(videoDuration / oneMarginTime) + 1)
 
         timeRange = oneMarginTime * 10
         // 显示时间 label 的个数 , -1 不够整倍数就不显示时间了
         let timeLabelCount = Int(wavTotalCount / 10)
-        contentWidth = CGFloat(wavTotalCount) * (frequencyWidth + frequencyMargin) + frequencyWidth + (cScreenWidth - cropViewWidth)
+        
+        contentWidth = CGFloat(wavTotalCount - 1) * (frequencyWidth + frequencyMargin) + frequencyWidth + (cScreenWidth - cropViewWidth)
         if contentWidth < scrollView.frame.width {
             contentWidth = scrollView.frame.width
         }
         scrollView.contentSize = CGSize(width: contentWidth, height: scrollView.frame.height)
         
+//        HHZPrint("框内个数:\(wavSelectCount), 总线条数:\(wavTotalCount), 框宽:\(cropViewWidth)")
         
         for index in 0 ... timeLabelCount {
             scrollView.viewWithTag(100 + index)?.removeFromSuperview()
@@ -241,9 +243,9 @@ class PQStuckPointCuttingView: UIView {
         // 整倍数
         let waveTotalCount = Int(wavTotalCount) / cFrequency.count
         // 余多少个未画的
-        var remainder = Int(ceil(CGFloat(wavTotalCount) - CGFloat(waveTotalCount * cFrequency.count)))
+        var remainder = Int(wavTotalCount % cFrequency.count)
         var totalWave: [CGFloat] = Array<CGFloat>.init()
-        // 1,先画整倍数个竖线
+//         1,先画整倍数个竖线
         for _ in 0 ..< waveTotalCount {
             totalWave = totalWave + cFrequency
         }
@@ -252,7 +254,7 @@ class PQStuckPointCuttingView: UIView {
         }
         // 1,再画余数个竖线
         if remainder > 0 {
-            totalWave = totalWave + cFrequency[0 ... remainder]
+            totalWave = totalWave + cFrequency[0 ... (remainder - 1)]
         }
 
         createWave(waveArr: totalWave)
@@ -267,9 +269,7 @@ class PQStuckPointCuttingView: UIView {
             return
         }
         let startIndex = scrollView.contentOffset.x / (frequencyWidth + frequencyMargin)
-        
-//        HHZPrint("startIndex is:\(startIndex) stuckPointStartTime is: \(stuckPointStartTime)")
-        let selectIndex = Int(ceil(startIndex + progress * CGFloat(wavSelectCount)))
+        let selectIndex = Int(floor(startIndex + progress * CGFloat(wavSelectCount)))
         if(selectIndex < lineLayerArray.count){
             let drawLayer:CAShapeLayer = lineLayerArray[selectIndex]
             BFLog(message: "progress is \(progress) i \(selectIndex) 命中的位置:\(CGFloat(selectIndex) * oneMarginTime)")