i added zoom to pinch on the UIView in my iPhone app. but i can't limit how much it zooms in and out. i want the limit of zooming out to the size of the original view. and i want the zooming to be reasonable. can some one help me?
i added these two codes:
&
i added these two codes:
Code:
- (void)viewDidLoad
{
UIPinchGestureRecognizer *twoFingerPinch = [[[UIPinchGestureRecognizer alloc]
initWithTarget:self
action:@selector(twoFingerPinch:)]
autorelease];
[[self view] addGestureRecognizer:twoFingerPinch];
}
&
Code:
- (void)twoFingerPinch:(UIPinchGestureRecognizer *)recognizer
{
NSLog(@"Pinch scale: %f", recognizer.scale);
CGAffineTransform transform = CGAffineTransformMakeScale(recognizer.scale, recognizer.scale);
// you can implement any int/float value in context of what scale you want to zoom in or out
self.view.transform = transform;
}
Last edited by a moderator: