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);

    }

          

  • 相关阅读:
    python基础学习4(内置函数)
    python基础学习5(包与模块)
    放弃用你的InnerHTML来输出HTML吧,jQuery Tmpl不详细讲解
    Entity Framework 4.1 CodeFirst实例
    .net企业库数据处理模块使用DAAB来开发应用
    行转列和列转行
    读懂这100这句话,你会懂得很多
    iis 6 下有关gzip 的有关配置
    jquery 设置 Select CheckBox Radio
    SQL函数说明大全
  • 原文地址:https://www.cnblogs.com/-ios/p/4788802.html
Copyright © 2011-2022 走看看