【发布时间】:2013-08-22 13:12:50
【问题描述】:
我有一个 UIViewController,它调用了一个 UIView:
我正在使用 UIPinchGesture 放大 UIView 我想要做的是根据缩放比例限制用户可以平移多少
即 “当前规模”
目前我使用的代码不允许平移,当 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];
}
一些方向,将不胜感激 - 谢谢!
【问题讨论】:
-
您正在使用平移或捏合手势或两者兼而有之?
-
我认为这可能对你有帮助。它对我有用。就像一个魅力。 stackoverflow.com/questions/1362718/…
-
@pratyusha - 我都在使用,Rajpuroht - 这是为了 UIScrollView : 和它的讨论速度,而不是限制空间
标签: ios uiview uigesturerecognizer zooming uipangesturerecognizer