动画行为
来源:互联网 发布:淘宝上有纯粮食酒吗 编辑:程序博客网 时间:2024/06/05 19:04
1.创建仿真者ReferenceView:仿真区域(参考系)
self.animator = [[UIDynamicAnimatoralloc] initWithReferenceView:self.view];
2.创建仿真行为 重力行为
UIGravityBehavior * gravity = [[UIGravityBehavioralloc] initWithItems:@[self.redView]];
2.1设置重力方向
方式一 (包括方向和大小)
gravity.gravityDirection = CGVectorMake(10, 10);
方式二
设置方向
gravity.angle= M_PI_4;
gravity.angle= M_PI_4;
设置大小 1000 points/second²
gravity.magnitude= 10;
3.把仿真行为添加到仿真者中
[self.animatoraddBehavior:gravity];
2.创建仿真行为(碰撞行为)
UICollisionBehavior* collision = [[UICollisionBehavioralloc]initWithItems:@[self.redView]];
UICollisionBehavior* collision = [[UICollisionBehavioralloc]initWithItems:@[self.redView]];
设置YES就是把仿真区域转化为碰撞的边界
collision.translatesReferenceBoundsIntoBoundary =YES;
弹性系数(0 ---- 1)
item.elasticity =0;
2.创建仿真行为(吸附)
UISnapBehavior* snap = [[UISnapBehavioralloc]initWithItem:self.redViewsnapToPoint:locP];
UISnapBehavior* snap = [[UISnapBehavioralloc]initWithItem:self.redViewsnapToPoint:locP];
阻尼系数(0 --- 1) 0:最抖动 1:最不抖动
snap.damping =0;
附着行为
- (instancetype)initWithItem:(id <UIDynamicItem>)item attachedToAnchor:(CGPoint)point;
元素附着到点
- (instancetype)initWithItem:(id <UIDynamicItem>)item offsetFromCenter:(UIOffset)offset attachedToAnchor:(CGPoint)point NS_DESIGNATED_INITIALIZER;
元素附着到指定点(根据center偏移)
- (instancetype)initWithItem:(id <UIDynamicItem>)item1 attachedToItem:(id <UIDynamicItem>)item2;
元素之间的附着
- (instancetype)initWithItem:(id <UIDynamicItem>)item1 offsetFromCenter:(UIOffset)offset1 attachedToItem:(id <UIDynamicItem>)item2 offsetFromCenter:(UIOffset)offset2 NS_DESIGNATED_INITIALIZER;
指定元素之间的附着点(根据每个元素的center偏移)
2.创建仿真行为(附着行为)
UIAttachmentBehavior * attachment = [[UIAttachmentBehavior alloc] initWithItem:self.redView attachedToAnchor:locP];
获取红色View的size
CGSize reSize = self.redView.bounds.size;
UIAttachmentBehaviorTypeItems,元素之间的附着
UIAttachmentBehaviorTypeAnchor元素和点的附着
附着行为 (刚性附着 弹性附着)
UIAttachmentBehavior* attachment = [[UIAttachmentBehavioralloc]initWithItem:self.redViewoffsetFromCenter:UIOffsetMake(-reSize.width/2, -reSize.height/2)attachedToAnchor:locP];
设置线长
attachment.length = 100;
CZView * view = (CZView*)self.view;
设置起点和终点
attachment.action= ^{
设置起点
view.startPoint= locP;
设置终点
view.endPoint = self.redView.center;
转换坐标点
view.endPoint= [self.viewconvertPoint:CGPointZerofromView:self.redView];
};
设置弹性附着 (同时设置以下两个属性)
频率
attachment.frequency= 0.5;
阻尼系数
频率
attachment.frequency= 0.5;
阻尼系数
attachment.damping =0.5;
2.创建仿真行为 平推
UIPushBehaviorModeContinuous, 持续
UIPushBehaviorModeInstantaneous 瞬时 一次性
UIPushBehavior * push = [[UIPushBehavioralloc] initWithItems:@[self.redView]mode:UIPushBehaviorModeInstantaneous];
0 0
- 动画行为
- silverlight动画行为
- UnityAI行为-----群组行为之群集动画
- 15.5.2 使用行为创建动画
- 动画时间轴的基本行为
- UIPushBehavior-动画效果:推移行为
- UIPushBehavior-动画效果:推移行为
- <图形图像,动画,多媒体> 读书笔记 --- 力学行为特性
- WPF动画结束后的行为方式
- Flex学习笔记_06 使用行为对象和动画效果_认识行为对象、行为和组件
- FLEX 笔记--组件的行为和动画效果
- Flex组件的行为和动画效果(实例)
- FLEX 笔记--组件的行为和动画效果
- iOS动画和特效(二)UIKit力学行为
- iOS动画和特效(二)UIKit力学行为
- 行为
- 行为
- Unity Mecanim动画的实现(十):动画混合树、子状态机和状态行为
- 《leetCode》:Symmetric Tree
- Tomcat与Eclipse集成
- PHP面试题
- Scala的object和class的区别
- 父类引用指向子类对象
- 动画行为
- Android TV-Handling TV Hardware
- html 富文本编辑(WYSIWYG)
- iOS 文字动画,文字逐个显示
- UVA 227 - Puzzle
- mac上创建并同时使用不同mysql版本的多个实例
- Java内存模型读书笔记-基础
- codeblocks快捷键(转)
- 《Java虚拟机原理图解》5. JVM类加载器机制与类加载过程