当我在单触手势识别器上平移图像时,它可以非常快速地移动图像,我可以减慢UIPanGestureRecognizer的速度,我的代码是
void PanImage (UIPanGestureRecognizer gestureRecognizer)
{
var image = gestureRecognizer.View;
if (gestureRecognizer.State == UIGestureRecognizerState.Began || gestureRecognizer.State == UIGestureRecognizerState.Changed)
{
var translation = gestureRecognizer.TranslationInView (window);
gestureRecognizer.View.Center = new PointF (gestureRecognizer.View.Center.X + translation.X, gestureRecognizer.View.Center.Y + translation.Y);
gestureRecognizer.SetTranslation (PointF.Empty, image);
}
}
答案 0 :(得分:0)
您从识别器计算的翻译可以除以一个因子来减慢平移效果。
它可以很容易地完成:
var factor =2;
gestureRecognizer.View.Center = new PointF (gestureRecognizer.View.Center.X + (translation.X/factor), gestureRecognizer.View.Center.Y + (translation.Y/factor));