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

    }

          

  • 相关阅读:
    关于跳槽你需要知道的
    Ping 命令的使用方法总结
    Linux 使用 su 切换用户提示 Authentication Failure 的解决方法
    《小强升职记——时间管理故事书》读书笔记
    记近期的几次面试经历
    每月书单_2014-06
    每月书单_2014-02
    交互式设计与用户体验
    读书笔记_探索式测试_混合探索式测试
    请慢慢移动……由于操作快慢导致的bug
  • 原文地址:https://www.cnblogs.com/-ios/p/4788802.html
Copyright © 2020-2023  润新知