zoukankan      html  css  js  c++  java
  • iOS 六大手势

    //六大手势的设置

          UIImageView *imV=(UIImageView*)[self.rv viewWithTag:101];

        //轻点

        UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc]initWithTarget:(self) action:@selector(tp:)];

        tap.numberOfTapsRequired=1;//点击几次反应

        tap.numberOfTouchesRequired=1;//几个手指点击

        [imV addGestureRecognizer:tap];

        //长按

        UILongPressGestureRecognizer *lp=[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(lop:)];

        lp.minimumPressDuration=2;//长按时间标准

        [imV addGestureRecognizer:lp];

        //轻扫(一次只能进行左右或者上下,不能四个方同时设置,可以做|(或)运算 )

        UISwipeGestureRecognizer *sw=[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swip:)];

        sw.numberOfTouchesRequired=1;//几个手指轻扫

        sw.direction=UISwipeGestureRecognizerDirectionDown;//向下轻扫

        sw.direction=UISwipeGestureRecognizerDirectionLeft;//向左轻扫

        sw.direction=UISwipeGestureRecognizerDirectionRight;//向右轻扫

        sw.direction=UISwipeGestureRecognizerDirectionUp;//向下轻扫

        [imV addGestureRecognizer:sw];

        //拖动

        UIPanGestureRecognizer *pan=[[UIPanGestureRecognizer alloc]

                                     initWithTarget:self action:@selector(pa:)];

        pan.minimumNumberOfTouches=1;//最小允许触控点

        pan.maximumNumberOfTouches=10;//最大允许触控点

        [imV addGestureRecognizer:pan];

        //捏合

        UIPinchGestureRecognizer *pin=[[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinc:)];

        [imV addGestureRecognizer:pin];

        //旋转

        UIRotationGestureRecognizer *rot=[[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rota:)];

        rot.rotation=2;//旋转的弧度

        [imV addGestureRecognizer:rot];

    //六大手势的响应事件      

    -(void)tp:(UITapGestureRecognizer*)sender1

    {

        NSLog(@"轻点");

    }

    -(void)lop:(UILongPressGestureRecognizer*)sender2

    {if(sender2.state==UIGestureRecognizerStateBegan){

        NSLog(@"长按");

    }

    }

    -(void)swip:(UISwipeGestureRecognizer*)sender3

    {

        NSLog(@"轻扫");

    }

    -(void)pa:(UIPanGestureRecognizer*)sender4

    {

        NSLog(@"拖动");

    }

    -(void)pinc:(UIPinchGestureRecognizer*)sender5

    {

        sender5.view.transform=CGAffineTransformMakeScale(sender5.scale, sender5.scale);

    }

    -(void)rota:(UIRotationGestureRecognizer*)sender6

    {

        sender6.view.transform=CGAffineTransformMakeRotation(sender6.rotation);

    }

          

  • 相关阅读:
    把java程序作为windows服务运行
    安装CentOS7出现dracut-initqueue timeout-starting…starting timeout scripts 解决办法
    在Linux下打包tar文件时添加密码的方法
    tk mybatis通用mapper,复杂and or条件查询
    firewalld 端口转发(机器内转发+机器间转发)
    postgresql中的序列nextval
    postgresql 建立索引
    索引面试题分析
    PostgreSQL不等于查询索引方法
    net-snmp开发中出现“Error opening specified endpoint"" ”的解决方案
  • 原文地址:https://www.cnblogs.com/-ios/p/4788802.html
Copyright © 2011-2022 走看看