I can get the UIPinchGestureRecognizer
handler to work with scaling an object but I don't want to scale I want to change the size. For example I have a UITextView
and I've attached a UIPinchGestureRecognizer
gesture to it and if the user pinches I want to change the width of the textview to match the pinch. I don't want to scale it so the UITextView
is larger(zooming).
I am doing the very same thing. I will update this post if I found how to do it.
Try this, it work for me (for UIView):
- (IBAction)handlePinchGesture:(UIGestureRecognizer *)sender {
static CGRect initialBounds;
UIView *_view = sender.view;
if (sender.state == UIGestureRecognizerStateBegan)
{
initialBounds = _view.bounds;
}
CGFloat factor = [(UIPinchGestureRecognizer *)sender scale];
CGAffineTransform zt = CGAffineTransformScale(CGAffineTransformIdentity, factor, factor);
_view.bounds = CGRectApplyAffineTransform(initialBounds, zt);
return;
}