zoukankan      html  css  js  c++  java
  • UITapGestureRecognizer+动画

    创建一个手势操作

      UITapGestureRecognizer点击手势

      UILongPressGestureRecognizer长按手势

      UISwipeGestureRecognizer滑动手势

       UIPinchGestureRecognizer按捏手势

    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(添加事件)];

            tapGesture.numberOfTapsRequired = 1;//需要点一下响应

            tapGesture.numberOfTouchesRequired = 1;//需要一根手指

            [self addGestureRecognizer:tapGesture];

    //    添加滑动手势

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

        swipeG.direction = UISwipeGestureRecognizerDirectionRight;

        swipeG.delegate = self;

        [_redView addGestureRecognizer:swipeG];

        //添加手捏手势

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

        pinchG.scale = 20;

       [_redView addGestureRecognizer:pinchG];

        //添加旋转手势

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

        [_redView addGestureRecognizer:rotationG];

    //旋转

    -(void)rotation:(UIRotationGestureRecognizer *)gesture{

        _redView.transform = CGAffineTransformRotate(_redView.transform, gesture.rotation);

    }

     //放大动画

       CABasicAnimation *scaleAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];

        scaleAnimation.fromValue = @1;

        if (type == kAnimationTypeInner) {

            scaleAnimation.toValue = @3;

        }else{

            scaleAnimation.toValue = @2;

        }

    //透明动画

    CABasicAnimation *opacityAniamtion = [CABasicAnimation animationWithKeyPath:@"opacity"];

        opacityAniamtion.fromValue = @1;

        opacityAniamtion.toValue = @0;

    //组动画,两个动画同时执行

    CAAnimationGroup *group = [CAAnimationGroup animation];

        group.animations = @[scaleAnimation,opacityAniamtion];

        group.duration = 0.5;

        group.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];

        return group;

  • 相关阅读:
    PostgreSQL 语法
    Linux 上安装 PostgreSQL
    Gitlab基础知识介绍
    Grafana 入门知识介绍
    数据卷容器
    Docker网络详解——原理篇
    Docker网络详细理解-容器网络互通
    搭建Elasitc stack集群需要注意的日志问题
    创建Elasticsearch集群并为它们配置TLS安全通信
    Elastic:为Elastic Docker部署设置安全
  • 原文地址:https://www.cnblogs.com/yangqinglong/p/5363327.html
Copyright © 2011-2022 走看看