|  | @@ -65,37 +65,41 @@ class BFIndirectionProgressView: UIView {
 | 
	
		
			
				|  |  |          items?.forEach { [weak self] model in
 | 
	
		
			
				|  |  |              _ = createItemView(minX: model.startCMTime.seconds * CGFloat(self?.percenWidth ?? 0), width: (model.endCMTime.seconds - model.startCMTime.seconds) * CGFloat(self?.percenWidth ?? 0))
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        (subviews.last as? BFThumImageView)?.isHiddenBord = true
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /// 设置进度
 | 
	
		
			
				|  |  |      /// - Parameters:
 | 
	
		
			
				|  |  | -    ///   - _: <#_ description#>
 | 
	
		
			
				|  |  | -    ///   - start: <#start description#>
 | 
	
		
			
				|  |  | -    ///   - progress: <#progress description#>
 | 
	
		
			
				|  |  | -    func setProgress(start: CGFloat = 0, progress: Float64) {
 | 
	
		
			
				|  |  | -//        BFLog(message: "录音进度--指示器Indir:progress=\(progress),duration=\(totalDuration),w=\(frame.width),perW=\(percenWidth),totalW:\(progress * percenWidth)")
 | 
	
		
			
				|  |  | -        if start * percenWidth >= frame.width {
 | 
	
		
			
				|  |  | +    ///   - _:
 | 
	
		
			
				|  |  | +    ///   - start: 开始录制的时间
 | 
	
		
			
				|  |  | +    ///   - progress: 当前录制时长
 | 
	
		
			
				|  |  | +    func setProgress(start: CMTime = .zero, progress: Float64) {
 | 
	
		
			
				|  |  | +        if start.seconds * percenWidth >= frame.width {
 | 
	
		
			
				|  |  |              frame.size.width = (superview as? UIScrollView)?.contentSize.width ?? 0
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        BFLog(1, message: "\(frame.size.width)")
 | 
	
		
			
				|  |  |          detectionAndCreateItem(start: start, progress: progress)
 | 
	
		
			
				|  |  | -        currentItem?.frame.size.width = progress < 0 ? 0 : progress * percenWidth
 | 
	
		
			
				|  |  | -        BFLog(message: "当前view:\(String(describing: currentItem))")
 | 
	
		
			
				|  |  | -        let vc = subviews.first { [weak self] sub in
 | 
	
		
			
				|  |  | -            (self?.currentItem?.frame.minX ?? 0) < sub.frame.minX && sub.frame.minX < (self?.currentItem?.frame.maxX ?? 0)
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        if vc != nil {
 | 
	
		
			
				|  |  | -            deletedView = vc
 | 
	
		
			
				|  |  | -            vc?.removeFromSuperview()
 | 
	
		
			
				|  |  | -            BFLog(message: "添加覆盖view-添加:deletedView = \(String(describing: deletedView))")
 | 
	
		
			
				|  |  | +        if let currentItem = currentItem {
 | 
	
		
			
				|  |  | +            let oldwidth = currentItem.frame.width
 | 
	
		
			
				|  |  | +            currentItem.frame.size.width = progress < 0 ? 0 : progress * percenWidth
 | 
	
		
			
				|  |  | +            BFLog(message: "当前view:\(String(describing: currentItem))")
 | 
	
		
			
				|  |  | +            
 | 
	
		
			
				|  |  | +            // 插入后后边的视图后移
 | 
	
		
			
				|  |  | +            subviews.forEach { subv in
 | 
	
		
			
				|  |  | +                if currentItem.frame.maxX < subv.frame.maxX {
 | 
	
		
			
				|  |  | +                    subv.frame = subv.frame.offsetBy(dx: (currentItem.width) - oldwidth, dy: 0)
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /// 检测并创建item
 | 
	
		
			
				|  |  |      /// - Parameter start: <#start description#>
 | 
	
		
			
				|  |  | -    func detectionAndCreateItem(start: CGFloat = 0, progress: Float64) {
 | 
	
		
			
				|  |  | +    func detectionAndCreateItem(start: CMTime = .zero, progress: Float64) {
 | 
	
		
			
				|  |  |          BFLog(message: "检测并创建item:\(start)")
 | 
	
		
			
				|  |  |          if currentItem == nil {
 | 
	
		
			
				|  |  |              deletedView = nil
 | 
	
		
			
				|  |  | +//            subviews[curr]
 | 
	
		
			
				|  |  |              currentItem = detectionItem(start: start, progress: progress)
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -105,8 +109,8 @@ class BFIndirectionProgressView: UIView {
 | 
	
		
			
				|  |  |      ///   - start: <#start description#>
 | 
	
		
			
				|  |  |      ///   - progress: <#progress description#>
 | 
	
		
			
				|  |  |      /// - Returns: <#description#>
 | 
	
		
			
				|  |  | -    func detectionItem(start: CGFloat = 0, progress: Float64) -> BFThumImageView? {
 | 
	
		
			
				|  |  | -        let newRange = CMTimeRange(start: CMTime(seconds: start, preferredTimescale: 1000), end: CMTime(seconds: start + progress, preferredTimescale: 1000))
 | 
	
		
			
				|  |  | +    func detectionItem(start: CMTime = .zero, progress: Float64) -> BFThumImageView? {
 | 
	
		
			
				|  |  | +        let newRange = CMTimeRange(start: start, duration: CMTime(seconds: progress, preferredTimescale: 1000))
 | 
	
		
			
				|  |  |          var currentIndex: Int?
 | 
	
		
			
				|  |  |          for (index, item) in subviews.enumerated() {
 | 
	
		
			
				|  |  |              let originRange = CMTimeRange(start: CMTime(seconds: item.frame.minX / percenWidth, preferredTimescale: 1000), end: CMTime(seconds: item.frame.width / percenWidth, preferredTimescale: 1000))
 | 
	
	
		
			
				|  | @@ -116,11 +120,22 @@ class BFIndirectionProgressView: UIView {
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          if currentIndex != nil {
 | 
	
		
			
				|  |  | -            BFLog(message: "检测存在重新创建")
 | 
	
		
			
				|  |  | +            BFLog(message: "检测存在取出")
 | 
	
		
			
				|  |  |              return subviews[currentIndex!] as? BFThumImageView
 | 
	
		
			
				|  |  |          } else {
 | 
	
		
			
				|  |  |              BFLog(message: "检测不存在重新创建:\(start)")
 | 
	
		
			
				|  |  | -            return createItemView(minX: start * percenWidth)
 | 
	
		
			
				|  |  | +            let v = createItemView(minX: start.seconds * percenWidth)
 | 
	
		
			
				|  |  | +            if subviews.count > 1 {
 | 
	
		
			
				|  |  | +                let vvs = subviews.sorted { v1, v2 in
 | 
	
		
			
				|  |  | +                    v1.rightX < v2.rightX
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                if let lastv = vvs.last(where: { vv in
 | 
	
		
			
				|  |  | +                    (vv.x < v.x) && (vv.rightX == v.x)
 | 
	
		
			
				|  |  | +                }) as? BFThumImageView {
 | 
	
		
			
				|  |  | +                    lastv.isHiddenBord = false
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            return v
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 |