对于动画UIDynamicAnimator的学习
2015-10-14 15:29
302 查看
正在第一步学习,看了一些其他人的博客,自己看了一下文档,这个类很简单,没有想象的难,但是可以写出漂亮的动画:
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];
//
// });
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];
//
// });
相关文章推荐
- siliverlight windowless=true 模式下禁止输入中文
- easyui datagrid组件应用
- 10、建造者模式(Builder)
- 【Android】Field requires API level 4 (current min is 1): android.os.Build.VERSION#SDK_INT
- CAShapeLayer 结合 UIBezierPath 画圆
- Zynq Reseving Physical Memory Issue
- TAILQ_QUEUE队列
- 用gitUI 提交 github
- jQuey中的$(document).read(function(){})与js中window.onload的区别?
- 错误The request sent by the client was syntactically incorrect ()的解决
- iOS开发UI篇—CALayer简介
- UIButton的UIEdgeInsets功能:设置button上的文字和图片的位置
- Error —— 打出log:finished with non-zero exit value 2
- puer实现前后端分离开发
- Android 数据查询query函数参数解析
- IOS-12-关于GCD多线程:dispatch_async 与 dispatch_get_global_queue 的使用方法
- IOS笔记UI--委托代理传值
- AmazeUi基础技能的学习(一)
- POJ3061 Subsequence 尺取法
- deviceQuery