• 五大手势


    //    点击收拾

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

        //    手指点击屏幕的次数

        tap.numberOfTapsRequired = 1;

        //    几个手指点击

        tap.numberOfTouchesRequired = 1;

        [self.view addGestureRecognizer:tap];

        

        //    长按

        UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(loagPress:)];

        //    最少按多少秒

        longPress.minimumPressDuration = 3;

        [self.view addGestureRecognizer:longPress];

        

        //    轻扫

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

        //    轻扫的方向

        swipe.direction = UISwipeGestureRecognizerDirectionLeft;

        [self.view addGestureRecognizer:swipe];

        

        

        //    拖动

        UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(pan:)];

        [pan requireGestureRecognizerToFail:swipe];

        [self.view addGestureRecognizer:pan];

        

        //    捏合

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

        

        [self.view addGestureRecognizer:pinch];

        

        //    旋转

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

        rotation.rotation = 1;

        [self.view addGestureRecognizer:rotation];

    }

    - (void)tick:(UITapGestureRecognizer *)tap

    {

    //  6、再出始化  这个对象的  地方  挂上代理

    //    NextViewController *next = [[NextViewController alloc]init];

    //    next.delegate = self;

    //    

    //    [self presentViewController:next animated:YES completion:nil];

        

        

        imageView.transform = CGAffineTransformIdentity;

        //    获取点击屏幕的位置

        NSLog(@"tap%f   %f",[tap locationInView:self.view].x,[tap locationInView:self.view].y);

        

        imageView.image = [UIImage imageNamed:@"yu.jpg"];

        imageView.alpha = 1;

        imageView.center = [tap locationInView:self.view];

        [UIView animateWithDuration:0.5 animations:^{

            imageView.alpha = 0.01;

        }];

    }

    - (void)mmmmmm

    {

        imageView.image = [UIImage imageNamed:@"yu.jpg"];

        imageView.alpha = 1;

    }

    - (void)loagPress:(UILongPressGestureRecognizer *)longPress

    {

        NSLog(@"longPress%f   %f",[longPress locationInView:self.view].x,[longPress locationInView:self.view].y);

    }

    - (void)swipe:(UISwipeGestureRecognizer *)swipe

    {

        NSLog(@"swipe%f   %f",[swipe locationInView:self.view].x,[swipe locationInView:self.view].y);

        

        self.view.frame = CGRectMake(self.view.bounds.size.width, 0, self.view.bounds.size.width, self.view.bounds.size.height);

        [UIView animateWithDuration:0.8 animations:^{

            self.view.frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height);

        }];

    }

    - (void)pan:(UIPanGestureRecognizer *)pan

    {

        //    获取拖动的位置

        imageView.image = [UIImage imageNamed:@"yu.jpg"];

        imageView.alpha = 1;

        imageView.center = [pan locationInView:self.view];

        

    }

    - (void)pinch:(UIPinchGestureRecognizer *)pinch

    {

        imageView.image = [UIImage imageNamed:@"yu.jpg"];

        imageView.alpha = 1;

        

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

        //    捏合的变化规模

        pinch.scale = 1;

        

    }

    - (void)rotation:(UIRotationGestureRecognizer *)rotation

    {

        

        imageView.image = [UIImage imageNamed:@"yu.jpg"];

        imageView.alpha = 1;

        

        //    使旋转手势上的视图旋转变化

        imageView.transform = CGAffineTransformMakeRotation(rotation.rotation);

        

    }

  • 相关阅读:
    OC和Swift中的UITabBar和UINaviGationBar的适配 [UITabbar在IPad中的适配]
    <iOS开发>之App上架流程(2017)
    iOS--LaunchImage启动页设置及问题解决
    去掉ambiguous expansion of macro警告
    iosapp开发者账号信息管理
    开发一个 app 有多难?
    Android SDK下载安装及配置教程
    抽象类和借口的区别
    array,vertor,arraylist,hashable,hashmap等几个易混淆概念的区别
    判断Set里的元素是否重复、==、equals、hashCode方法研究-代码演示
  • 原文地址:https://www.cnblogs.com/wukun16/p/4814805.html
Copyright © 2020-2023  润新知