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;

  • 相关阅读:
    Socket经验记录
    有了WCF,Socket是否已人老珠黄?
    更新Svn客户端后,右键菜单中没有TortoiseSVN了
    线程已被中止 “Thread was being aborted”
    c# 温故而知新: 线程篇(一)
    SOCKET是多线程安全的吗? [问题点数:40分,结帖人CSDN]
    <base href=""/> 的应用
    Python Twisted 框架中 socket通信
    本人作品-〉VPS应用>Discuz网页斗地主插件
    浅析 c# Queue
  • 原文地址:https://www.cnblogs.com/yangqinglong/p/5363327.html
Copyright © 2011-2022 走看看