zoukankan      html  css  js  c++  java
  • 单双击手势

     //添加手势

    BOOL            _large;

    //双击手势

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

            doubleTap.numberOfTapsRequired = 2;

            [imgView addGestureRecognizer:doubleTap];

      //单机手势    

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

            singleTap.numberOfTapsRequired = 1;

            [imgView addGestureRecognizer:singleTap];

            [singleTap requireGestureRecognizerToFail:doubleTap];

    //单机手势

    - (void)singleTap:(UITapGestureRecognizer *)gesture

    {

        UIImageView *imgView = (UIImageView *)gesture.view;

        UIWindow *window = [[UIApplication sharedApplication] keyWindow];

        self.view.backgroundColor = [UIColor clearColor];

        scroll.backgroundColor = [UIColor clearColor];

        [window addSubview:imgView];

        [imgView removeFromSuperview];

        [self dismissViewControllerAnimated:NO completion:nil];

    }

    - (void)doubleTap:(UITapGestureRecognizer *)gesture

    {

        UIScrollView *scl = (UIScrollView *)gesture.view.superview;

        

        if (scl.zoomScale == scl.maximumZoomScale) {

            

            [scl setZoomScale:1.0 animated:YES];

            _large = NO;

            _zoomingScrollView = nil;

            return;

        }

        

        if (_large) {

            

            [scl setZoomScale:1.0 animated:YES];

            _large = NO;

            _zoomingScrollView = nil;

            

        }else{

            

            CGPoint location = [gesture locationInView:gesture.view];

            [scl zoomToRect:CGRectMake(location.x, location.y, 1, 1) animated:YES];

            _large = YES;

            _zoomingScrollView = scl;

        }

    }

  • 相关阅读:
    java 第三次实验作业关于封装
    java String类实验作业随笔
    java 第一次基础实践
    英语四级冲刺笔记---谓语动词的时态下
    英语四级冲刺笔记——语法篇二
    英语四级冲刺笔记——语法篇一
    java面向对象---对象容器
    java--面向对象---访问属性
    java面向对象---对象初始化
    java面向对象---成员变量和成员函数
  • 原文地址:https://www.cnblogs.com/liuting-1204/p/5993033.html
Copyright © 2011-2022 走看看