pin捏合缩放手势 放大缩小的时候方向会停不下来
Closed this issue · 5 comments
sum123 commented
用这个属性recognizer.velocity可以解决
// 缩放后的candle宽度 let newCandleWidth = theme.candleWidth * (recognizer.velocity > 0 ? (1 + kLineScaleFactor) : (1 - kLineScaleFactor))
sum123 commented
框架写的不错,关于滑动的时候重绘,视觉上会有一格一卡的感觉。有思路解决么
zyphs21 commented
sum123 commented
我改了一下这里的代码 减少了刷新次数
`override open func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey: Any]?, context: UnsafeMutableRawPointer?) {
if keyPath == #keyPath(UIScrollView.contentOffset) && enableKVO {
// print("in klineview scrollView?.contentOffset.x " + "(scrollView.contentOffset.x)")
// 当滚动间隙大于1个K线柱的时候 才刷新视图
if abs(preRenderOffsetX - scrollView.contentOffset.x) < (theme.candleWidth+theme.candleGap), scrollView.contentSize.width > scrollView.width {
return
}
// 拖动 ScrollView 时重绘当前显示的 klineview
kLine.contentOffsetX = scrollView.contentOffset.x
kLine.renderWidth = scrollView.frame.width
kLine.drawKLineView(mainDrawString: mainDrawString, secondDrawString: secondDrawString, lineType: lineType)
...
preRenderOffsetX = scrollView.contentOffset.x
}
}`