我正在尝试用来UIPanGestureRecognizer
翻转 UIView。我正在使用下面的代码来处理翻转视图,
- (void)handlePan:(UIPanGestureRecognizer*)gesture{
CGPoint translation = [gesture translationInView:self.view];
NSLog(@"PAN X VALUE %f", translation.x );
double percentageOfWidth = translation.x / (gesture.view.frame.size.width / 2);
float angle = (percentageOfWidth * 100) * M_PI_2 / 180.0f;
CALayer *layer = testView.layer;
CATransform3D flipTransform = CATransform3DIdentity;
flipTransform.m34 = -0.002f;
flipTransform = CATransform3DRotate(flipTransform, angle, 0.0f, 1.0f, 0.0f);
layer.transform = flipTransform;
}
我的问题是当我平移时,有时会发生一些快速跳跃,我相信那是因为translation.x
(PAN X VALUE)值从前面的几个点跳跃,就我而言,我需要它非常平滑。
非常感谢任何帮助。
提前致谢。