self.view.backgroundColor = [UIColor whiteColor];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 200, 300)];
imageView.center = self.view.center;
imageView.image = [UIImage imageNamed:@"1.jpg"];
imageView.contentMode = UIViewContentModeScaleToFill;
imageView.userInteractionEnabled = YES; // 开启用户交互
// imageView.image = [UIImage imageNamed:@"2.jpg"];
[self.view addSubview:imageView];
1.tap 点击、轻拍
// UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
//
// tap.numberOfTapsRequired = 2; // 执行方法需要轻拍的次数
// tap.numberOfTouchesRequired = 1; // 需要的手指数
//
//
将手势赋给视图
// [imageView addGestureRecognizer:tap];
// [tap release];
//
2.长按
// UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress:)];
// [imageView addGestureRecognizer:longPress];
longPress.numberOfTapsRequired = 1;
// longPress.minimumPressDuration = 1; // 判定为长按手势的时间 默认为0.5秒
//
// longPress.allowableMovement = 200; // 在判定过程中,允许用户手指移动的距离
//
// [longPress release];
//
// 3.捏合手势
UIPinchGestureRecognizer *pinch = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinch:)];
[imageView addGestureRecognizer:pinch];
[pinch release];
//
4.拖拽(平移)
// UIPanGestureRecognizer *pan =[[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(pan:)];
// [imageView addGestureRecognizer:pan];
// [pan release];
//
// 5.旋转
// UIRotationGestureRecognizer *ratation = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotation:)];
// [imageView addGestureRecognizer:ratation];
// [ratation release];
6.轻扫
// UISwipeGestureRecognizer *swip = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swip:)];
// [imageView addGestureRecognizer:swip];
//
// swip.direction = UIDeviceOrientationPortraitUpsideDown;
swip.numberOfTouchesRequired = 1;
//
// [swip release];
// 7.边缘
// UIScreenEdgePanGestureRecognizer *screen = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(screen:)];
// screen.edges = UIRectEdgeLeft;
//
// [imageView addGestureRecognizer:screen];
// [screen release];
//
// [imageView release];
// Do any additional setup after loading the view.
}
#pragma mark - 边缘事件
- (void)screen:(UIScreenEdgePanGestureRecognizer *)screen {
NSLog(@"