Ios Dual-finger kneading to zoom in and out images

Source: Internet
Author: User

 


The distance between two fingers is enlarged or reduced.

 


Use-(void) touchesMoved :( NSSet *) touches withEvent :( UIEvent *) event.

TouchesMoved runs whenever the finger moves on the screen.

 


1. Check the number of fingers

NSArray * touchesArr = [[event allTouches] allObjects];
NSLog (@ "Number of fingers % d", [touchesArr count]);

 


2. Check the coordinates of the two fingers to calculate the distance between the two fingers.

P1 = [[touchesArr objectAtIndex: 0] locationInView: self. view];
P2 = [[touchesArr objectAtIndex: 1] locationInView: self. view];

 


3. When the calculation distance increases, the image is increased and the distance decreases. Use the frame of imageview to control the image size.


ImageView. frame = CGRectMake (imgFrame. origin. x-addwidth/2.0f, imgFrame. origin. y-addheight/2.0f, imgFrame. size. width, imgFrame. size. height );

 

 

 


 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.