• iOS学习笔记27-手势1


    -(void)pinchGesture

    {

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

        [self.view addGestureRecognizer:pinch];

    }

    -(void)pinch:(UIPinchGestureRecognizer *)pinch{

        float scale = pinch.scale;

        pinch.view.transform = CGAffineTransformScale(pinch.view.transform, scale, scale);

        

        if (scale >1) {

            self.gestureLabel.text =@"啮合放大";

        }else{

        

            self.gestureLabel.text = @"缩小";

        }

    }

    -(void)addTapGesture

    {

        /**

         *一个手指单击

         **/

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

        tap.numberOfTouchesRequired = 1;

        tap.numberOfTapsRequired = 1;

        [self.view addGestureRecognizer:tap];

        

        

        /**

         *一个手指双击

         **/

        UITapGestureRecognizer *tap2 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(doubleTap:)];

        tap2.numberOfTapsRequired = 2;

        [self.view addGestureRecognizer:tap2];

        

        

        /**

         *手势识别的互斥属性

         **/

        //当单击和双击同时出现在同一个视图上时,只能实现一个

        [tap requireGestureRecognizerToFail:tap2];

        

        

        

        /**

         *两个手指单击

         **/

        UITapGestureRecognizer *tap3 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(singleTwoTap:)];

        tap3.numberOfTouchesRequired = 2;

        [self.view addGestureRecognizer:tap3];

        

        [tap2 requireGestureRecognizerToFail:tap3];

        

    }

    -(void)swipeGesture

    {

        

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

        swipe.direction = UISwipeGestureRecognizerDirectionDown;

        [self.view addGestureRecognizer:swipe];

    }

    -(void)swipe:(UISwipeGestureRecognizer *)swipe

    {

        self.gestureLabel.text = @"下清扫";

    }

    -(void)singleTwoTap:(UITapGestureRecognizer *)tap

    {

        self.gestureLabel.text = @"两个手指单击";

    }

    -(void)doubleTap:(UITapGestureRecognizer *)tap

    {

        self.gestureLabel.text = @"一个手指双击";

    }

    -(void)Tap:(UITapGestureRecognizer *)tap{

        self.gestureLabel.text = @"一个手指单击";

    }

  • 相关阅读:
    Total Video Converter v3.71 注册码
    Web下载文件
    语音朗读
    SQLSERVER 删除重复记录
    Windows8[启用IIS8 asp.net功能]
    黑链代码
    在ASP.NET中防止注入攻击[翻译]
    Oracle 正确删除archivelog文件
    浅谈网站黑链检测和清除的方法
    解密SQLServer2000加密存储过程,函数,触发器,视图
  • 原文地址:https://www.cnblogs.com/adodo/p/5221707.html
Copyright © 2020-2023  润新知