zoukankan      html  css  js  c++  java
  • IOS-开发中手势的处理

    手势识别
    一、1.点按
    UITapGestureRecognizer
    2.长按
    UILongPressGestureRecognizer
    if (UIGestureRecognizerStateBegan == recongnizer.state) {//如果自己的状态等于开始
    [recongnizer.view setTransform:CGAffineTransformMakeRotation(M_PI)];//就设置transform旋转属性为180;
    }else if(UIGestureRecognizerStateEnded == recongnizer.state){
    [recongnizer.view setTransform:CGAffineTransformIdentity];
    }
    3.拖动
    UIPanGestureRecognizer
    if (recongnizer.state == UIGestureRecognizerStateChanged) {
    CGPoint deltaPoint = [recongnizer translationInView:self.view];//判断在父视图平移的位置
    recongnizer.view.transform = CGAffineTransformMakeTranslation(deltaPoint.x, deltaPoint.y);
    }else if(recongnizer.state == UIGestureRecognizerStateEnded){
    recongnizer.view.transform = CGAffineTransformIdentity;
    }
    4.捏合
    UIPinchGestureRecognizer
    if (recongnizer.state == UIGestureRecognizerStateChanged) {
    recongnizer.view.transform = CGAffineTransformMakeScale(recongnizer.scale, recongnizer.scale);
    }else if(recongnizer.state == UIGestureRecognizerStateEnded){
    [UIView animateWithDuration:0.5 animations:^{
    recongnizer.view.transform = CGAffineTransformIdentity;
    }];
    }
    5.清扫
    UISwipeGestureRecognizer
    if (recongnizer.direction == UISwipeGestureRecognizerDirectionUp) {
    NSLog(@"向上");
    }else if (recongnizer.direction == UISwipeGestureRecognizerDirectionDown){
    NSLog(@"向下");
    }else if (recongnizer.direction == UISwipeGestureRecognizerDirectionLeft){
    NSLog(@"向左");
    }else if (recongnizer.direction == UISwipeGestureRecognizerDirectionRight){
    NSLog(@"向右");
    }
    6.旋转
    UIRotationGesturecognizer
    if (recongnizer.state == UIGestureRecognizerStateChanged) {
    recongnizer.view.transform = CGAffineTransformMakeRotation(M_PI);
    }
    二、综上所述:发现
    1>捏合,拖动,旋转,都需要判断状态改变和状态结束
    2>清扫需要设置方向,并且判断方向,默认是向右清扫
    3>长按需要判断状态开始,和状态结束
    4>其他可按需求判断

  • 相关阅读:
    Flink 的datastreamAPI 以及function函数的调用,性能调优
    Spark Shuffle原理、Shuffle操作问题解决和参数调优
    Spark学习之JavaRdd
    Redis学习笔记--Redis数据过期策略详解==转
    Elasticsearch 数据搜索篇·【入门级干货】===转
    HBase二级索引的设计(案例讲解)
    C中指针符*和取址符&
    java 中,如何获取文件的MD5值呢?如何比较两个文件是否完全相同呢?
    Mysql数据库的加密与解密
    Lucene 分词
  • 原文地址:https://www.cnblogs.com/yinqiang/p/3486802.html
Copyright © 2011-2022 走看看