|
@@ -58,6 +58,7 @@ class PQStuckPointCuttingView: UIView {
|
|
|
private var oneMarginTime: CGFloat = 0
|
|
|
|
|
|
private var isDrawLine: Bool = false
|
|
|
+ private var startDraw = true
|
|
|
|
|
|
// 保存已经绘制的竖线用于变色使用
|
|
|
var lineLayerArray: Array = Array<CAShapeLayer>.init()
|
|
@@ -290,22 +291,32 @@ class PQStuckPointCuttingView: UIView {
|
|
|
/// progress <#progress description#>
|
|
|
func updateProgress(progress: CGFloat) {
|
|
|
|
|
|
-
|
|
|
if(progress <= 0 || lineLayerArray.count == 0 || progress.isNaN){
|
|
|
BFLog(message: "progress is error ")
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- BFLog(message: "progress is Start ************* ")
|
|
|
-
|
|
|
let startIndex = scrollView.contentOffset.x / (frequencyWidth + frequencyMargin)
|
|
|
- let selectIndex = Int(floor(startIndex + progress * CGFloat(wavSelectCount)))
|
|
|
+ if startDraw { // 第一个波纹
|
|
|
+ startDraw = false
|
|
|
+ let selectIndex = Int(ceil(startIndex))
|
|
|
+ if(selectIndex < lineLayerArray.count){
|
|
|
+ let drawLayer:CAShapeLayer = lineLayerArray[selectIndex]
|
|
|
+ if drawLayer.strokeColor != UIColor.hexColor(hexadecimal: PQBFConfig.shared.styleColor.rawValue).cgColor{
|
|
|
+ drawLayer.strokeColor = UIColor.hexColor(hexadecimal: PQBFConfig.shared.styleColor.rawValue).cgColor
|
|
|
+ drawLayer.setNeedsDisplay()
|
|
|
+ drawLayer.layoutIfNeeded()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let selectIndex = Int(ceil(startIndex + progress * CGFloat(wavSelectCount)))
|
|
|
if(selectIndex < lineLayerArray.count){
|
|
|
let drawLayer:CAShapeLayer = lineLayerArray[selectIndex]
|
|
|
// BFLog(1, message: "progress is \(progress) i \(selectIndex) 命中的位置:\(CGFloat(selectIndex) * oneMarginTime)")
|
|
|
if drawLayer.strokeColor != UIColor.hexColor(hexadecimal: PQBFConfig.shared.styleColor.rawValue).cgColor{
|
|
|
drawLayer.strokeColor = UIColor.hexColor(hexadecimal: PQBFConfig.shared.styleColor.rawValue).cgColor
|
|
|
drawLayer.setNeedsDisplay()
|
|
|
+ drawLayer.layoutIfNeeded()
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -319,6 +330,8 @@ class PQStuckPointCuttingView: UIView {
|
|
|
|
|
|
// 竖线恢复到原有色值
|
|
|
func resetDefaultsColor(clearData:Bool = true) {
|
|
|
+ startDraw = false
|
|
|
+
|
|
|
for layer in lineLayerArray {
|
|
|
layer.strokeColor = UIColor.hexColor(hexadecimal: "#999999").cgColor
|
|
|
layer.setNeedsDisplay()
|
|
@@ -365,9 +378,9 @@ class PQStuckPointCuttingView: UIView {
|
|
|
lineLayer.path = linePath.cgPath
|
|
|
lineLayer.fillColor = UIColor.black.cgColor
|
|
|
|
|
|
- // 推荐的开始起点是虚线
|
|
|
+ // 推荐的开始起点是虚线 减0.0001因为精度问题
|
|
|
// BFLog(1, message: "suggestRhythmStartTime is \(suggestRhythmStartTime)")
|
|
|
- if oneMarginTime * CGFloat(i) >= suggestRhythmStartTime && !isDrawLine {
|
|
|
+ if oneMarginTime * CGFloat(i) >= (suggestRhythmStartTime-0.0001) && !isDrawLine {
|
|
|
isDrawLine = true
|
|
|
linePath.move(to: CGPoint(x: originX, y: -10))
|
|
|
// 终点
|