用Easing函数实现碰撞效果

工程中需要的源码请从这里下载:

https://github.com/YouXianMing/EasingAnimation

源码:

//
// ViewController.m
// EasingView
//
// Created by YouXianMing on 15/1/17.
// Copyright (c) 2015年 YouXianMing. All rights reserved.
// #import "ViewController.h"
#import "YXEasing.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad]; // 显示的view
UIView *showView = [[UIView alloc] initWithFrame:CGRectMake(, -, , )];
showView.backgroundColor = [UIColor clearColor];
showView.layer.borderColor = [UIColor redColor].CGColor;
showView.layer.borderWidth = .f;
showView.layer.cornerRadius = .f;
[self.view addSubview:showView]; // 关键帧动画
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position"]; // 设置值
[animation setValues:[YXEasing calculateFrameFromPoint:showView.center
toPoint:CGPointMake(showView.center.x, showView.center.y + )
func:BounceEaseOut
frameCount:]]; // 设置持续时间
animation.duration = .f; // 执行动画效果
showView.center = CGPointMake(showView.center.x, showView.center.y + );
[showView.layer addAnimation:animation forKey:nil];
} @end

最新文章

  1. gulp-babel使用
  2. struts2学习笔记--使用servletAPI实现ajax的一个小Demo
  3. scrapy1_官网教程
  4. NEFU 503 矩阵求解 (非01异或的高斯消元)
  5. Nodejs日志管理包
  6. mysql truncate带有被引用外键的表时报错解决方法
  7. 自定义 404 与 500 错误页面,URL 地址不会重定向(一)
  8. 提高你的Java代码质量吧:使用valueof前必须进行校验
  9. oracle xe在centos下的安装(更)
  10. css样式表的知识点总结
  11. cf1076E Vasya and a Tree (线段树)
  12. 廖雪峰Java6 IO编程-3Reader和Writer-1Reader
  13. 为什么要用dubbo,dubbo和zookeeper关系
  14. #pragma data_seg() 共享数据// MyData段 // 进程 // DLL
  15. 由js文件中引入另外的js文件想到的
  16. 利用 ASP.NET 的内置功能抵御 Web 攻击 (1)
  17. struts2读取request,session,application中的值
  18. Apache版本hadoop-2.6.0.tar.gz平台下搭建Hue
  19. Spring Cloud构建微服务架构(四)分布式配置中心
  20. 栈和队列ADT -数据结构(C语言实现)

热门文章

  1. Android进程管理
  2. python-组播
  3. MySQL之mysql命令使用详解
  4. mysql 索引的简单使用
  5. PTA (Advanced Level) 1023 Have Fun with Numbers
  6. Mongo db 与mysql 语法比较
  7. Angular2 不明真相第一个Demo例子
  8. [javaSE] 网络编程(TCP-并发上传图片)
  9. OpenGL开发入门
  10. 实例-PHP_SELF、 SCRIPT_NAME、 REQUEST_URI区别-获取前台公用文-dirname-PHP的"魔术常量"-str_replace