IOS开发 抛物线
2015-12-29 18:10
351 查看
-(void)throwObject:(UIView *)obj from:(CGPoint)start to:(CGPoint)end height:(CGFloat)height
duration:(CGFloat)duration{
self.showingView = obj;
//初始化抛物线的路径
CGMutablePathRef path =
CGPathCreateMutable();
CGFloat cpx = (start.x + end.x) /
2;
CGFloat cpy = height;
CGPathMoveToPoint(path,
NULL, start.x, start.y);
CGPathAddQuadCurveToPoint(path,
NULL, cpx, cpy, end.x, end.y);
CAKeyframeAnimation *animation = [CAKeyframeAnimation
animationWithKeyPath:@"position"];
animation.path = path;
CABasicAnimation *scaleAnimation = [CABasicAnimation
animationWithKeyPath:@"transform.scale"];
scaleAnimation.autoreverses =
YES;
scaleAnimation.toValue = [NSNumber
numberWithFloat:0.6];
CABasicAnimation *rotateAnimation = [CABasicAnimation
animationWithKeyPath:@"transform.rotation.y"];
scaleAnimation.fromValue = [NSNumber
numberWithFloat:1];
rotateAnimation.toValue = [NSNumber
numberWithFloat:6.0 *
M_PI];
rotateAnimation.duration =
0.8;
CAAnimationGroup *groupAnimation = [CAAnimationGroup
animation];
groupAnimation.delegate =
self;
groupAnimation.repeatCount =
1;
groupAnimation.duration = duration;
groupAnimation.removedOnCompletion =
NO;
groupAnimation.animations =
@[scaleAnimation,animation,rotateAnimation];
[obj.layer addAnimation:groupAnimation
forKey:nil];
}
duration:(CGFloat)duration{
self.showingView = obj;
//初始化抛物线的路径
CGMutablePathRef path =
CGPathCreateMutable();
CGFloat cpx = (start.x + end.x) /
2;
CGFloat cpy = height;
CGPathMoveToPoint(path,
NULL, start.x, start.y);
CGPathAddQuadCurveToPoint(path,
NULL, cpx, cpy, end.x, end.y);
CAKeyframeAnimation *animation = [CAKeyframeAnimation
animationWithKeyPath:@"position"];
animation.path = path;
CABasicAnimation *scaleAnimation = [CABasicAnimation
animationWithKeyPath:@"transform.scale"];
scaleAnimation.autoreverses =
YES;
scaleAnimation.toValue = [NSNumber
numberWithFloat:0.6];
CABasicAnimation *rotateAnimation = [CABasicAnimation
animationWithKeyPath:@"transform.rotation.y"];
scaleAnimation.fromValue = [NSNumber
numberWithFloat:1];
rotateAnimation.toValue = [NSNumber
numberWithFloat:6.0 *
M_PI];
rotateAnimation.duration =
0.8;
CAAnimationGroup *groupAnimation = [CAAnimationGroup
animation];
groupAnimation.delegate =
self;
groupAnimation.repeatCount =
1;
groupAnimation.duration = duration;
groupAnimation.removedOnCompletion =
NO;
groupAnimation.animations =
@[scaleAnimation,animation,rotateAnimation];
[obj.layer addAnimation:groupAnimation
forKey:nil];
}
相关文章推荐
- iOS界面布局之三——纯代码的autoLayout及布局动画 iOS8及VFL语言
- IOS页面自动布局 之 NSLayoutConstraint基础篇
- xcode7、iOS9 设置启动图片(Launch Image)
- iOS 7 代码布局适配
- iOS消息推送机制的实现
- iOS 第三方库汇总(超全!!!!)
- iOS学习之利用关联对象让类别有添加属性效果
- iOS开发日记57-详解Quartz 2D
- Ios - 计算Label文字中字体的frame - 实用代码
- IOS之同步请求、异步请求、GET请求、POST请求
- IOS-通过代码⾃自定义cell(cell的⾼高度不⼀一致)
- 简析iOS开发设计模式的各自分析对比
- IOS离线教程下载与Dash的使用
- IOS之相同URL不同图片识别
- iOS -- 如何封装一个元素是字典的数组
- iOS中NSPredicate 查询、搜索(详解)、判断是否是手机号码
- ios9新特性及遇到的一些问题解决方案
- iOS字符串自动计算文本的宽和高
- j48源码学习笔记(三)InfoGainSplitCrit, GainRatioSplitCrit,熵的计算
- 关于电话号码在IOS下面显示白色的