我有一个 UIViewController,它调用一个 UIView:
我正在使用 UIPinchGesture 放大 UIView 我想要做的是根据缩放比例限制用户可以平移多少
即“currentScale”
目前我使用的代码不允许平移,当 currentScale(缩放的数量)小于 1.1 倍缩放时,但如果 1.1 很棒,它允许平移,但这允许 UIView 可以无限制地平移和移动,我希望能够将其平移量设置为其边界:当前代码
if (currentScale <= 1.1f) {
// Use this to animate the position of your view to where you want
[UIView animateWithDuration: 0.5
delay: 0
options: UIViewAnimationOptionCurveEaseOut
animations:^{
CGPoint finalPoint = CGPointMake(self.view.bounds.size.width/2,
self.view.bounds.size.height/2);
recognizer.view.center = finalPoint; }
completion:nil];
}
else {
recognizer.view.center = CGPointMake(recognizer.view.center.x + translation.x,
recognizer.view.center.y + translation.y);
[recognizer setTranslation:CGPointZero inView:self.view];
}
一些方向,将不胜感激 - 谢谢!