• 对于动画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];

    //        

    //    });

  • 相关阅读:
    Java线程优先级(Priority)
    Java同步锁(synchronized)、锁(lock)以及死锁
    Java实现多线程的三种方式(3) ------实现Callable<V>接口
    Java实现多线程的三种方式(2) ------实现Runnable接口
    Java实现多线程的三种方式(1) ------继承Thread类
    Spring AOP(2) --基于配置文件方式配置
    Spring AOP(1) --基于注解方式配置
    Spring IOC容器基于注解方式装配Bean
    Spring IOC容器基于配置文件装配Bean(9) ------bean的SpEL用法
    Python基础教程学习目录
  • 原文地址:https://www.cnblogs.com/runningsoul/p/4877575.html
Copyright © 2020-2023  润新知