ios动力特效,最重要的一点 属性保持(写了动力特效但是没效果的原因就在这里)
@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.
}
最新文章
- React Native知识7-TabBarIOS组件
- Java基础学习-- 继承 的简单总结
- storm实战:基于storm,kafka,mysql的实时统计系统
- C++指针比较的问题
- 在《The DevOps 2.0 Toolkit》测试时要作的ansible的配置更改
- ddl语句
- 湖大 11404 manacher
- codeforces 630B Moore's Law
- svn 钩子 post-commit 出现255错误解决办法
- 树形遍历(java)---孩子双亲表示法
- VNC-Server installation on CentOS 7
- linux 开通ftp账号
- 你不明白 String 类别
- asp.net MVC实现文章的“上一篇下一篇”
- iOS 按钮连续提交执行一次(如留言提交,多次拍照问题)
- Linux 创建子进程执行任务
- java 安装以及配置
- HDU5384-Hotaru's problem-Manacher
- 阿里云k8s私有仓库registry操作管理
- ThinkPHP内置日志记录