I have a UIViewController, which calls a UIView:
I am using UIPinchGesture to zoom into the UIView What I want to do is limit how much a user can pan, according to the zoomed Scale
i.e. "currentScale"
Currently the code I'm using allows no panning, when the currentScale (Amount zoomed) is less than 1.1x zoomed, but if it is great that 1.1 it allows pannin, but this allows the UIView to be panned and moved about without bounds, I want to be able to set its panning amount to its boundaries : current code
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];
}
Some direction, would be very appreciated -thank you !