//
// ViewController.m
// swipe手势
//
// Created by tianshangrenjian on 15/7/2.
// Copyright © 2015年 tianshangrenjian. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *iconImage;
@property (assign, nonatomic) CGFloat xRotation;
@end
@implementation ViewController
//swip清扫
- (void)swipxx
{
NSLog(@"swip清扫");
}
- (void)longPress
{
NSLog(@"longpress");
}
- (void)rotationSwip
{
self.xRotation+=M_PI_4;
CGAffineTransform form=CGAffineTransformMakeRotation(self.xRotation);
[self.iconImage setTransform:form];
}
- (void)rotationSwixpnew:(UIRotationGestureRecognizer *)gesture
{
CGAffineTransform form=CGAffineTransformMakeRotation(gesture.rotation);
[self.iconImage setTransform:form];
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.iconImage.image=[UIImage imageNamed:@"IMG_0006.jpg"];
self.xRotation=0;
//旋转
UIRotationGestureRecognizer *rotation=[[UIRotationGestureRecognizer alloc ] initWithTarget:self action:@selector(rotationSwixpnew:)];
[self.iconImage addGestureRecognizer:rotation];
//----长按屏幕
UILongPressGestureRecognizer *longPress=[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress)];
longPress.minimumPressDuration=2;
[self.view addGestureRecognizer:longPress];
//-------清扫
UISwipeGestureRecognizer *swipe=[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipxx)];
swipe.direction=UISwipeGestureRecognizerDirectionRight ;
swipe.numberOfTouchesRequired=2;
self.iconImage.userInteractionEnabled=YES;
[self.iconImage addGestureRecognizer:swipe];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end