@property (nonatomic, strong) UIDynamicItemBehavior *square1PropertiesBehavior;

@property (nonatomic, strong) UIDynamicItemBehavior *square2PropertiesBehavior;

@property (nonatomic, strong) UIDynamicAnimator *animator;

@property(nonatomic,strong)UIDynamicAnimator*dy;

@end

@implementation ViewController

- (void)viewDidLoad {

[super viewDidLoad];

UIView * apple = [[UIView alloc] initWithFrame:CGRectMake(40,40, 40, 40)];

apple.backgroundColor = [UIColor redColor];

[self.view addSubview:apple];

UIDynamicAnimator *animator = [[UIDynamicAnimator alloc] initWithReferenceView:self.view];

UIGravityBehavior *gravityBeahvior = [[UIGravityBehavior alloc] initWithItems:@[apple]];

UICollisionBehavior *collisionBehavior = [[UICollisionBehavior alloc] initWithItems:@[apple]];

UIDynamicItemBehavior*behavior = [[UIDynamicItemBehavior alloc] initWithItems:@[apple]];

//behavior.elasticity = ;

collisionBehavior.translatesReferenceBoundsIntoBoundary = YES;

[animator addBehavior:gravityBeahvior];

[animator addBehavior:collisionBehavior];

[animator addBehavior:behavior];

self.dy = animator; //属性保持才能有动画效果

}

- (void)didReceiveMemoryWarning {

[super didReceiveMemoryWarning];

// Dispose of any resources that can be recreated.

}

最新文章

  1. React Native知识7-TabBarIOS组件
  2. Java基础学习-- 继承 的简单总结
  3. storm实战:基于storm,kafka,mysql的实时统计系统
  4. C++指针比较的问题
  5. 在《The DevOps 2.0 Toolkit》测试时要作的ansible的配置更改
  6. ddl语句
  7. 湖大 11404 manacher
  8. codeforces 630B Moore's Law
  9. svn 钩子 post-commit 出现255错误解决办法
  10. 树形遍历(java)---孩子双亲表示法
  11. VNC-Server installation on CentOS 7
  12. linux 开通ftp账号
  13. 你不明白 String 类别
  14. asp.net MVC实现文章的“上一篇下一篇”
  15. iOS 按钮连续提交执行一次(如留言提交,多次拍照问题)
  16. Linux 创建子进程执行任务
  17. java 安装以及配置
  18. HDU5384-Hotaru's problem-Manacher
  19. 阿里云k8s私有仓库registry操作管理
  20. ThinkPHP内置日志记录

热门文章

  1. [App]华为P6设置与Xamarin Studio连通测试
  2. APMServ5.2.6 升级PHP版本 到高版本 5.3,5.4
  3. JavaScript高级程序设计38.pdf
  4. CC2530芯片介绍
  5. 构建CMDB的一些启发
  6. windows下redis的安装配置和php扩展使用phpredis
  7. B树,B-树,B+树,B*树
  8. hdoj 2816 I Love You Too
  9. 一次服务器CPU占用率高的定位分析
  10. 【python自动化第六篇:面向对象】