用Easing函数实现碰撞效果
2024-10-19 12:42:36
用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
最新文章
- gulp-babel使用
- struts2学习笔记--使用servletAPI实现ajax的一个小Demo
- scrapy1_官网教程
- NEFU 503 矩阵求解 (非01异或的高斯消元)
- Nodejs日志管理包
- mysql truncate带有被引用外键的表时报错解决方法
- 自定义 404 与 500 错误页面,URL 地址不会重定向(一)
- 提高你的Java代码质量吧:使用valueof前必须进行校验
- oracle xe在centos下的安装(更)
- css样式表的知识点总结
- cf1076E Vasya and a Tree (线段树)
- 廖雪峰Java6 IO编程-3Reader和Writer-1Reader
- 为什么要用dubbo,dubbo和zookeeper关系
- #pragma data_seg() 共享数据// MyData段 // 进程 // DLL
- 由js文件中引入另外的js文件想到的
- 利用 ASP.NET 的内置功能抵御 Web 攻击 (1)
- struts2读取request,session,application中的值
- Apache版本hadoop-2.6.0.tar.gz平台下搭建Hue
- Spring Cloud构建微服务架构(四)分布式配置中心
- 栈和队列ADT -数据结构(C语言实现)
热门文章
- Android进程管理
- python-组播
- MySQL之mysql命令使用详解
- mysql 索引的简单使用
- PTA (Advanced Level) 1023 Have Fun with Numbers
- Mongo db 与mysql 语法比较
- Angular2 不明真相第一个Demo例子
- [javaSE] 网络编程(TCP-并发上传图片)
- OpenGL开发入门
- 实例-PHP_SELF、 SCRIPT_NAME、 REQUEST_URI区别-获取前台公用文-dirname-PHP的";魔术常量";-str_replace