手势

 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(@"

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值