iOS gesture recognition-zoom and rotate

Source: Internet
Author: User

//
Viewcontroller.m
zwj-gesture Recognition-zoom and rotate
//
Created by ZWJ on 14-9-16.
Copyright (c) 2014 ZWJ. All rights reserved.
//

#import "ViewController.h"

@interface Viewcontroller () <UIGestureRecognizerDelegate>

@property (Weak, nonatomic) Iboutlet Uiimageview *imgview;

@end

@implementation Viewcontroller

-(void) viewdidload
{
[Super Viewdidload];

[Self testpinchges];
[Self testrotationges];
}

/**
* Test pinch gesture
*/
-(void) testpinchges{
Uipinchgesturerecognizer *pinch = [[Uipinchgesturerecognizer alloc] initwithtarget:self action: @selector (Pincheview :)];
[Self.imgview Addgesturerecognizer:pinch];
Pinch.delegate = self;
}
-(void) Pincheview: (Uipinchgesturerecognizer *) pinch
{
NSLog (@ "%f", Pinch.scale);
Pinch.view.transform = Cgaffinetransformscale (Pinch.view.transform, Pinch.scale, Pinch.scale);
Pinch.scale = 1;
}

/**
* Test Rotation gestures
*/
-(void) testrotationges{
Uirotationgesturerecognizer *rotation = [[Uirotationgesturerecognizer alloc]initwithtarget:self Action: @selector ( Rotationview:)];
[Self.imgview addgesturerecognizer:rotation];
Rotation.delegate = self;
}

-(void) Rotationview: (Uirotationgesturerecognizer *) rotation{
CGFloat rotationf = rotation.rotation;
NSLog (@ "Rotating%f", rotationf);

Rotation.view.transform = Cgaffinetransformrotate (Rotation.view.transform, rotation.rotation);
rotation.rotation = 0;

NSLog (@ "1111---%@", self.view);
NSLog (@ "2222---%@", rotation.view);
}

/**
* Implement Proxy method
*/
-(BOOL) Gesturerecognizer: (Uigesturerecognizer *) Gesturerecognizer Shouldrecognizesimultaneouslywithgesturerecognizer: (Uigesturerecognizer *) othergesturerecognizer{
return YES;
}
@end

iOS gesture recognition-zoom and rotate

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.