|
@@ -61,6 +61,7 @@ class PQStuckPointCuttingView: UIView {
|
|
|
|
|
|
// 保存已经绘制的竖线用于变色使用
|
|
|
var lineLayerArray: Array = Array<CAShapeLayer>.init()
|
|
|
+ var lastDrawedLineIndex : Int = 0
|
|
|
|
|
|
// 裁剪区的相素大小
|
|
|
var cropViewWidth: CGFloat = adapterWidth(width: 250)
|
|
@@ -296,15 +297,18 @@ class PQStuckPointCuttingView: UIView {
|
|
|
}
|
|
|
|
|
|
let startIndex = scrollView.contentOffset.x / (frequencyWidth + frequencyMargin)
|
|
|
+ lastDrawedLineIndex = max(lastDrawedLineIndex, Int(ceil(startIndex)))
|
|
|
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)")
|
|
|
+ while(selectIndex < lineLayerArray.count && selectIndex > lastDrawedLineIndex){
|
|
|
+ let drawLayer:CAShapeLayer = lineLayerArray[lastDrawedLineIndex]
|
|
|
if drawLayer.strokeColor != UIColor.hexColor(hexadecimal: PQBFConfig.shared.styleColor.rawValue).cgColor{
|
|
|
+ BFLog(1, message: "progress is \(progress) i \(lastDrawedLineIndex) 命中的位置:\(CGFloat(lastDrawedLineIndex) * oneMarginTime)")
|
|
|
drawLayer.strokeColor = UIColor.hexColor(hexadecimal: PQBFConfig.shared.styleColor.rawValue).cgColor
|
|
|
drawLayer.setNeedsDisplay()
|
|
|
drawLayer.layoutIfNeeded()
|
|
|
}
|
|
|
+ lastDrawedLineIndex += 1
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -317,6 +321,7 @@ class PQStuckPointCuttingView: UIView {
|
|
|
|
|
|
// 竖线恢复到原有色值
|
|
|
func resetDefaultsColor(clearData:Bool = true) {
|
|
|
+ lastDrawedLineIndex = 0
|
|
|
for layer in lineLayerArray {
|
|
|
layer.strokeColor = UIColor.hexColor(hexadecimal: "#999999").cgColor
|
|
|
layer.setNeedsDisplay()
|
|
@@ -336,7 +341,7 @@ class PQStuckPointCuttingView: UIView {
|
|
|
}
|
|
|
|
|
|
/// 生成波纹
|
|
|
- /// - Parameter waveArr: <#waveArr description#>
|
|
|
+ /// - Parameter waveArr: <#waveArr description#> // warning 有崩溃 _buffer _ArrayBuffer<CoreGraphics.CGFloat> wavearr为CoreGraph.CGFloat数组
|
|
|
/// - Returns: <#description#>
|
|
|
func createWave(waveArr: [CGFloat]) {
|
|
|
for (i, power) in waveArr.enumerated() {
|