简体   繁体   中英

How can I use pinch zoom(UIPinchGestureRecognizer) to change width of a UIView

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 UIView and I've attacked a UIPinchGestureRecognizer gesture to it and if the user pinches I want to change the width of the UIView to match the pinch. I don't want to scale it so the UIView is larger(zooming)

If you have the UIPinchGestureRecognizer call a method pinch, you can do:

- (void) pinch:(UIPinchGestureRecognizer *)pinch
{
    CGRect frame = [self.view frame];
    frame.size.width = frame.size.width * pinch.scale;
    [self.view setFrame:frame];
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM