Here are the zoom gestures and pinch gestures:
Directly on the code:
1 #import "ViewController.h"2 3 @interfaceViewcontroller () <UIGestureRecognizerDelegate>4 5 @end6 7 @implementationViewcontroller8 9- (void) Viewdidload {Ten [Super Viewdidload]; One //additional setup after loading the view, typically from a nib. A - //If you need to rotate and scale simultaneously we also need to implement a protocol uigesturerecognizerdelegate - the -UIImage *image = [UIImage imagenamed:@"2.jpg"]; - -Uiimageview *imageview =[[Uiimageview alloc]init]; +Imageview.frame = CGRectMake ( -, $, -, -); -imageview.userinteractionenabled =YES; +Imageview.image =image; A [Self.view Addsubview:imageview]; at - //Add a zoom gesture (pinch gesture) -_pinges =[[Uipinchgesturerecognizer alloc]initwithtarget:self Action: @selector (pinchact:)]; - - [ImageView addgesturerecognizer:_pinges]; - in //Create a rotation gesture -_rotges =[[Uirotationgesturerecognizer alloc]initwithtarget:self Action: @selector (rotges:)]; to + [ImageView addgesturerecognizer:_rotges]; - the //set up the protocol agent *_pinges.Delegate=Self ; $_rotges.Delegate=Self ;Panax Notoginseng - } the +- (void) Pinchact: (Uipinchgesturerecognizer *) pin{ A //get the monitor image view (i.e. the ImageView object above) theUiimageview *iview = (Uiimageview *) Pin.view; + //matrix transformation Calculation and assignment of Image view Objects - //transform represents the transformation of a graphic $ //Cgaffinetransformscale produces a new matrix by zooming in $ //P1 the original matrix - //P2 Scale in X-direction - //p3 scale in y direction theIview.transform =Cgaffinetransformscale (Iview.transform, Pin.scale, Pin.scale); - Wuyi the //To return a scale value to a unit value -Pin.scale =1; Wu - } About $- (void) Rotges: (Uirotationgesturerecognizer *) rotges{ - - //Get rotated Objects -Uiimageview *iview = (Uiimageview *) Rotges.view; A //Calculate rotation changes and assign values +Iview.transform =cgaffinetransformrotate (Iview.transform, rotges.rotation); the - //Select angle Clear 0; $Rotges.rotation =0; the the the } the //Implementing protocol Methods - //can I respond to two gestures at the same time in //if the return value is yes you can respond at the same time; the-(BOOL) Gesturerecognizer: (Uigesturerecognizer *) Gesturerecognizer Shouldrecognizesimultaneouslywithgesturerecognizer: (Uigesturerecognizer *) othergesturerecognizer{ the About returnYES; the}
This makes it easy to zoom (pinch) and rotate the view.
Uigesture Basic gestures