• 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;

  • 相关阅读:
    golang学习----nil值
    CentOS配置multipath
    oracle基础-创建表空间
    oracle数据库基本命令
    CentOS使用fdisk扩展磁盘空间
    CentOS增加swap分区
    VMWARE错误-"VirtualInfrastructure.Utils.ClientsXml"的类型初始值设定项引发异常
    windows server 2008远程桌面最大连接数设置
    windows sserver 2008远程桌面端口修改
    iSCSI配置
  • 原文地址:https://www.cnblogs.com/yangqinglong/p/5363327.html
Copyright © 2020-2023  润新知