我有一个UIViewController,它调用一个UIView:的iOS - 设置最小/最大限制平移
我使用UIPinchGesture放大到UIView的 我想要做的就是限制用户多少可以平移,根据缩放比例
即 “currentScale”
目前我使用的代码允许无平移,当currentScale(金额放大)小于1.1倍变焦,但如果它是伟大的,1.1它允许pannin,但这允许UIView被平移和移动无边界,我希望能够et panning amount to its boundaries:当前代码
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];
}
某些方向,将非常感激 - 谢谢!
您正在使用平移还是捏手势? –
我认为这可能有助于你。它对我来说很有用。 http://stackoverflow.com/questions/1362718/scroll-a-background-in-a-different-speed-on-a-uiscrollview –
@pratyusha - 我使用两个,Rajpuroht - 这是为了UIScrollView:讨论速度,而不是限制空间 –