UIPinchGestureRecognizer手势

来源:互联网 发布:av小次郎 最新域名 编辑:程序博客网 时间:2024/05/01 18:48

ViewController.h

@interface ViewController : UIViewController{

    

    //矩阵

    CGAffineTransform oldTransform;


}

@property (retainnonatomicIBOutlet UIImageView *mouse;


@end


#import "ViewController.h"


@interface ViewController ()


@end


@implementation ViewController

@synthesize mouse;



-(void)pinchStart:(UIPinchGestureRecognizer *)myPinch{

    

    

    if((myPinch.state == UIGestureRecognizerStateBegan)||(myPinch.state == UIGestureRecognizerStateChanged)){

        

        mouse.transform =CGAffineTransformScale(oldTransform, myPinch.scale, myPinch.scale);  

    }

    

    if(myPinch.state ==UIGestureRecognizerStateEnded){

        oldTransform = mouse.transform;

    }

}

- (void)viewDidLoad

{

    [super viewDidLoad];

    

    UIPinchGestureRecognizer *myPinch = [[UIPinchGestureRecognizer alloc]initWithTarget:selfaction:@selector(pinchStart:)];

    

    [mouse addGestureRecognizer:myPinch];

    

    oldTransform = mouse.transform;

    [myPinch release];


}

原创粉丝点击