• ios -动画


     self.collectionview.pagingEnabled = YES;

        //1.CollectionView 添加长按手势

        UILongPressGestureRecognizer *longTap = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longHandle:)];

        [ self.collectionview addGestureRecognizer:longTap];

     

    }

    //2.长按方法

    -(void)longHandle:(UILongPressGestureRecognizer *)gesture

    {

        switch (gesture.state) {

            case UIGestureRecognizerStateBegan:

            {

                NSIndexPath *indexPath = [self.collectionview indexPathForItemAtPoint:[gesture locationInView:self.collectionview]];

                if (indexPath == nil) {

                    break;

                }

                [self.collectionview beginInteractiveMovementForItemAtIndexPath:indexPath];

                //cell.layer添加抖动手势

                for (UICollectionViewCell *cell in [self.collectionview visibleCells]) {

                    [self starShake:cell];

                }

                break;

            }

            case UIGestureRecognizerStateChanged:

            {

                [self.collectionview updateInteractiveMovementTargetPosition:[gesture locationInView:self.collectionview]];

                break;

            }

            case UIGestureRecognizerStateEnded:

            {

                

                [self.collectionview endInteractiveMovement];

                //cell.layer移除抖动手势

                for (UICollectionViewCell *cell in [self.collectionview visibleCells]) {

                    [self stopShake:cell];

                }

                break;

            }

            default:

                [self.collectionview cancelInteractiveMovement];

                break;

        }

        

    }

     

    //抖动动画

    - (void)starShake:(UICollectionViewCell*)cell{

        

        CAKeyframeAnimation * keyAnimaion = [CAKeyframeAnimation animation];

        keyAnimaion.keyPath = @"transform.rotation";

        keyAnimaion.values = @[@(-3 / 180.0 * M_PI),@(3 /180.0 * M_PI),@(-3/ 180.0 * M_PI)];//度数转弧度

        keyAnimaion.removedOnCompletion = NO;

        keyAnimaion.fillMode = kCAFillModeForwards;

        keyAnimaion.duration = 0.3;

        keyAnimaion.repeatCount = MAXFLOAT;

        [cell.layer addAnimation:keyAnimaion forKey:@"cellShake"];

    }

    - (void)stopShake:(UICollectionViewCell*)cell{

        [cell.layer removeAnimationForKey:@"cellShake"];

    }

  • 相关阅读:
    [原创]Java开发如何在线打开Word文件
    [原创]Java开发在线打开编辑保存Word文件(支持多浏览器)
    [原创]java操作word(一)
    [原创]java对word文档的在线打开
    修改ZEN CART系统遇到的问题总结(不断更新)
    MYSQL 5.1 插入空值BUG 解决方法
    zen cart 安装 商品批量管理插件(easy_populate_v1257_utf8)出现的问题
    C# 区分无线网卡和有线网卡的MAC
    C# Flash的背景透明处理
    c#Windows服务
  • 原文地址:https://www.cnblogs.com/shenlaiyaoshi/p/8616143.html
Copyright © 2020-2023  润新知