zoukankan      html  css  js  c++  java
  • 【iOS开发】UIKit Dynamics




    UIKit Dynamics :  一个模拟真实的动画和交互系统,具有可组合、可重用和声明的特点。


    UIKit Dynamics Framwork:






    Reference Viewe: 参照物,为Dynamic system提供坐标系。


    UIDynamicAnimator :物理引擎。会记录你添加到引擎中的行为,并提供全局上下文。


    UIDynamicBehavior: 行为模型


    1.UIAttachmentBehavior

    2.UICollisionBehavior

    3.UIDynamicItemBehavior

    4.UIGravityBehavior

    5.UIPushBehavior

    6.UISnapBehavior


    dynamic行为可以是组合的,也可以被继承,可以在任意时间内进行添加和移除;必须是在二维空间进行。



    自由落体运动实例:


    1.添加受力物体


    @interface ViewController (){

    UIView *motionView;

    }


    motionView = [[UIViewallocinitWithFrame:CGRectMake(100,90,100,100)];

    motionView = [UIColorgrayColor];

    [self.view motionView];



    2.添加引擎,并提供参照物


    UIDynamicAnimator *animator;


    animator = [[UIDynamicAnimatoralloc initWithReferenceView:self.view;


    3.给引擎添加重力行为


    UIGravityBehavior *gravity;


    gravity = [[UIGravityBehavioralloc]initWithItems:@[motionView]];

    [animatoraddBehavior:gravity];


    4.添加边界


    UICollisionBehavior *collision;


    collision = [[UICollisionBehavioralloc]initWithItems:@[motionView]];

    //把参照物的bound设置为边界

    collision.translatesReferenceBoundsIntoBoundary =YES;

    [animatoraddBehavior:collision];



    源码下载:

    csdn上  github上 














  • 相关阅读:
    手机电阻式和电容式触摸屏九大区别
    AMBA、AHB、APB总线简介
    PHY芯片
    S3C2440A Memory design
    ARM、DSP、FPGA的技术特点和区别
    LPC2104的Boot与Remap详解(一)
    Memorymapped I/O
    Motherboard Chipsets and the Memory Map
    88f6282 notes
    太网设计FAQ:以太网MAC和PHY
  • 原文地址:https://www.cnblogs.com/in1ts/p/3572470.html
Copyright © 2011-2022 走看看