• 对于动画UIDynamicAnimator的学习


    正在第一步学习,看了一些其他人的博客,自己看了一下文档,这个类很简单,没有想象的难,但是可以写出漂亮的动画:

    1.没有初步整理,附上一些方法,随后写出一个Demo

     UIView *aView = [[UIView alloc]initWithFrame:CGRectMake(100, 50, 100, 100)];

        aView.backgroundColor = [UIColor lightGrayColor];

        [self.view addSubview:aView];

        aView.transform = CGAffineTransformRotate(aView.transform, 45);

        //重力作用

        UIDynamicAnimator *anmimaor = [[UIDynamicAnimator alloc]initWithReferenceView:self.view];

        UIGravityBehavior *beah = [[UIGravityBehavior alloc]initWithItems:@[aView]];

        

        self.beah = beah;

        [anmimaor addBehavior:beah];

        

        

        

        

        

        

        //碰撞作用

        UICollisionBehavior *collisionBehavior = [[UICollisionBehavior alloc]initWithItems:@[aView]];

        collisionBehavior.translatesReferenceBoundsIntoBoundary = YES;

        [anmimaor addBehavior:collisionBehavior];

        self.collisionBehavior = collisionBehavior;

        collisionBehavior.collisionDelegate = self;

        

        //链接锚点

    //    UIAttachmentBehavior *attachmentBeah = [[UIAttachmentBehavior alloc]initWithItem:aView attachedToAnchor:CGPointMake(300, 400)];

    //    [anmimaor addBehavior:attachmentBeah];

        

        

        

        UIPushBehavior *ppushBeah = [[UIPushBehavior alloc]initWithItems:@[aView] mode:UIPushBehaviorModeContinuous];

        ppushBeah.pushDirection = CGVectorMake(10, 19);

        [anmimaor addBehavior:ppushBeah];

        

        

     

        //这个是吸附作用

    //    UISnapBehavior *snapBeah = [[UISnapBehavior alloc]initWithItem:aView snapToPoint:CGPointMake(10, 20)];

    //    snapBeah.damping = 20;

    //    

    //    [anmimaor addBehavior:snapBeah];

        

        self.Animator = anmimaor;

     

     

    //    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{

    //       

    //        [aView removeFromSuperview];

    //        

    //    });

  • 相关阅读:
    C++ Operate FTP
    md /mdd /ml /mt/mtd
    从MySpace基于.NET平台的六次重构经历,来感受分布式系统。
    分布式缓存BeIT Memcached简介
    Asp.Net应用程序中为什么要MachineKey?如何生成MachineKey?
    马云飞机上写长贴:再一次和新同事们谈谈看法
    memcached完全剖析
    ESET ESS/EAV 5 正式版 中英文32/64位 (注册版) 下载
    Windows下的.NET+ Memcached安装
    在 ASP.NET 環境下使用 Memcached 快速上手指南
  • 原文地址:https://www.cnblogs.com/runningsoul/p/4877575.html
Copyright © 2020-2023  润新知