@IBAction func OnRightSwipeGesture(sender: UIPanGestureRecognizer) {
let translated = sender.translationInView(self.view);
let diffTrans = (translated.y - previouslyTranslated.y) / 75;
sum += diffTrans;
print(sum);
colorWheel.transform = CGAffineTransformMakeRotation(sum);
previouslyTranslated = translated;
}
在这个函数中,我每次调用后都会添加翻译的差异。然后,当我把手指从设备上移开并尝试制作新手势时,总和被重置为0.总和被声明在课程顶部,我非常困惑......
答案 0 :(得分:0)
你应该检查一下手势识别器的state
,并且只在等于UIGestureRecognizerStateChanged
时更新你的变量。