1 #import "NJViewController.h"2 3 @interfaceNjviewcontroller () <UIGestureRecognizerDelegate>4@property (Weak, nonatomic) Iboutlet Uiimageview *IconView;5 6 @end7 8 @implementationNjviewcontroller9 Ten- (void) Viewdidload One { A [Super Viewdidload]; - - [self pichtest]; the [self rotationtest]; - } - - //the bool value returned by the method determines whether the view can respond to multiple gestures at the same time +-(BOOL) Gesturerecognizer: (Uigesturerecognizer *) Gesturerecognizer Shouldrecognizesimultaneouslywithgesturerecognizer: (Uigesturerecognizer *) Othergesturerecognizer - { +NSLog (@"%@ - %@", Gesturerecognizer.class, Othergesturerecognizer.class); A returnYES; at } - -- (void) Pichtest - { - //pinch gesture -Uipinchgesturerecognizer *pinch =[[Uipinchgesturerecognizer alloc] init]; inPinch.Delegate=Self ; - to [Self.iconview addgesturerecognizer:pinch]; + [Pinch addtarget:self action: @selector (Pinchview:)]; - } the * $- (void) Pinchview: (Uipinchgesturerecognizer *) PinchPanax Notoginseng { - //self.iconView.transform = Cgaffinetransformmakescale (Pinch.scale, pinch.scale); theSelf.iconView.transform =Cgaffinetransformscale (Self.iconView.transform, Pinch.scale, Pinch.scale); + APinch.scale =1.0; the } + -- (void) Rotationtest $ { $ //Rotate -Uirotationgesturerecognizer *gesture =[[Uirotationgesturerecognizer alloc] init]; -Gesture.Delegate=Self ; the - [Self.iconview addgesturerecognizer:gesture];Wuyi [Gesture addtarget:self action: @selector (Rotationview:)]; the } - Wu- (void) Rotationview: (Uirotationgesturerecognizer *) Gesture - { About //each time starting from the original position $ //self.iconView.transform = cgaffinetransformmakerotation (gesture.rotation); - //increments a radian on the incoming transform basis -Self.iconView.transform =cgaffinetransformrotate (Self.iconView.transform, gesture.rotation); - //clear 0 of the rotated arc (note that the arc of the current finger is not zeroed, but the arc of rotation is clear 0) AGesture.rotation =0;//If you can't understand it, just remember, OK. + } the - @end
iOS gesture recognition rotation + zoom