UIKit Dynamics的中文名称:有叫UIKit动力,也有叫UIKit动力模型和UIKit动态或者动态UI,叫什么名没关系,理解就含义就能够了。html
什么是UIKit Dynamics ?app
UIKit动力提供了一个模拟真实世界中力学相关的动画和交互系统。好比重力、碰撞和吸附等。UIKit动力具备可组合、可重用和声明式的特色。个人理解就是把游戏开发中的物理引擎的搬过来了。
ide
首先简单看几点基础知识:学习
一、UIDynamicAnimator:
动画
a、ui
A dynamic animator provides physics-related capabilities and animations for its dynamic items, and providesthe context for those animations. It does this by intermediating between the underlying iOS physics engineand dynamic items, via behavior objects you add to the animator. this
UIDynamicAnimator类的做用是起到衔接动力项和view,很重要。
spa
b、.net
能够有这些做用:(固然,英文不用都理解,明白大体意思就能够,后面看代码就明白了)代理
All types of dynamic animators share the following characteristics:
Each dynamic animator is independent of other dynamic animators you create
You can associate a given dynamic item with multiple behaviors, provided those behaviors belong to thesame animator
An animator automatically pauses when all its items are at rest, and automatically resumes when a behaviorparameter changes or a behavior or item is added or removed
c、
初始化方法:
– initWithReferenceView:
Initializes a dynamic animator with a specified view as its reference view.
d、
UIDynamicAnimator在view中实现的时候,也有其代理方法:
dynamicAnimatorDidPause: 动力项在view中被Pause的时候时候回调此方法
dynamicAnimatorWillResume: 动力项在view中Resume的时候时候回调此方法
二、一些动力项(都是模拟真实物体在现实中的行为)
UIAttachmentBehavior 吸附
UICollisionBehavior 碰撞
UIDynamicItemBehavior 活力(相似真实物体,有活力,更逼真)
UIGravityBehavior 重力(物体受重力影响自由下落)
UIPushBehavior 推进
UISnapBehavior objects 仓促
下看就去看代码吧:官网demo(http://pan.baidu.com/share/link?shareid=1092885049&uk=3674861929)
UIDynamicAnimator_Class 文档下载直通车:http://pan.baidu.com/share/link?shareid=1108425560&uk=3674861929
更多内容请查看官网:https://developer.apple.com/wwdc/schedule/
这个爱学习的人的博客也颇有用:http://www.cocoachina.com/newbie/basic/2013/0612/6393.html
注意:
一、若是看代码,或者本身创建项目的时候,出现IOS7的build错误了,那就看看这里吧 http://blog.csdn.net/zfpp25_/article/details/9106573
二、看代码时,会遇到 anchorPoint (锚点)这个游戏中经常使用的概念,不明白没关系,看这里 http://blog.csdn.net/zfpp25_/article/details/8641651
虽然官网的例子也有问题,不过新东西,代码太少,将就看吧,因为工做忙,因此没那么多空闲时间,就到这里吧。祝学习快乐。