1
我有這樣的功能:斯威夫特復位transitionInView
func moveAxes(recognizer: UIPanGestureRecognizer) {
switch recognizer.state {
case .Changed:
var changePoint = recognizer.translationInView(self)
axesCenter = CGPoint(x: axesCenter.x + changePoint.x, y: axesCenter.y + changePoint.y)
print("x: \(changePoint.x) y: \(changePoint.y)")
changePoint.x = 0.0
changePoint.y = 0.0
default:
break
}
}
應該在我的UIView軸移動。問題是,
changePoint.x = 0.0
changePoint.y = 0.0
不重置覆蓋的距離,它保持加起來,所以我的軸開始加速遠離移動點。如何重置覆蓋距離以避免此問題?
p.s. axesCenter
被初始化爲x: frame.midX
,y: frame.midY