CAniamtion 基本使用
CAAnimation(抽象)<NSCoding, NSCopying, CAMediaTiming, CAAction>
QuartzCore框架的基本继承结构 -> CATransition
CAAnimation(抽象) -> CAPropertyAnimation -> CABasicAnimation
-> CAKeyframeAnimation
-> CAAnimationGroup
//渐变
UIButton *b = (UIButton *)sender;
CATransition *transition = [CATransition animation];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromRight;
[self.imageview.layer addAnimation:transition forKey:@"transition"];
self.imageview.image = [UIImage imageNamed:@"avatar.jpg"]; //基本
CABasicAnimation *baseProperty = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
baseProperty.fromValue = [NSNumber numberWithDouble:1.0];
baseProperty.toValue = [NSNumber numberWithDouble:0.4];
baseProperty.duration = 1.0;
baseProperty.removedOnCompletion = NO;
baseProperty.fillMode = kCAFillModeForwards;
baseProperty.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
[self.imageview.layer addAnimation:baseProperty forKey:@"baseProperty"]; //关键帧
//动画组
CAKeyframeAnimation *keyFrameAniamtion = [CAKeyframeAnimation animationWithKeyPath:@"position"]; CGMutablePathRef mutablePath = CGPathCreateMutable();
CGPathMoveToPoint(mutablePath, NULL, self.imageview.frame.origin.x, self.imageview.frame.origin.y);
CGPathAddLineToPoint(mutablePath, NULL, , );
keyFrameAniamtion.path = mutablePath; keyFrameAniamtion.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]; CAKeyframeAnimation *keyframe2 = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation"];
NSArray *values2 = [NSArray arrayWithObjects:[NSNumber numberWithFloat:], [NSNumber numberWithFloat:(M_PI * )], nil];
keyframe2.values = values2;
keyframe2.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]; CAAnimationGroup *group = [CAAnimationGroup animation];
group.removedOnCompletion = NO;
group.fillMode = kCAFillModeForwards;
group.animations = [NSArray arrayWithObjects:keyFrameAniamtion, keyframe2, nil];
group.duration = 2.0;
[self.imageview.layer addAnimation:group forKey:@"group"];
CAniamtion 基本使用的更多相关文章
随机推荐
- StringBuilder 和 StringBuffer
这两者唯一的不同就在于,StringBuffer是线程安全的,而StringBuilder不是.当然线程安全是有成本的,影响性能,而字符串对象及操作,大部分情况下,没有线程安全的问题,适合使用Stri ...
- PHP责任链设计模式
<?php //责任链设计模式 /** * 每个对象,储存着对自己上级的引用, * 如果自己处理不了,交给上一级. */ class board{ protected $power=1; pro ...
- pulltorefresh滚动到底部
如果用ListView,让它滚动到顶部,一般是这样写的: if (!listView.isStackFromBottom()) { listView.setStackFromBottom(true); ...
- C#----我对坐标系的理解和图形转动
目录: 设置图形的旋转 设置坐标轴的反向 图形的旋转 参考一个文章:http://www.bccn.net/Article/kfyy/vc/jszl/200601/3008.html ; 目标:让Dr ...
- 改造rm命令为mv
:刚在群里面看到小伙伴误操作把服务器上重要的文件给删掉了,于是google了下,找到一篇文章把rm命令改造成mv命令,源博客如下:http://blog.csdn.net/dataspark/arti ...
- Xcode设置
1. 在Search Paths中设置相对路径 径是以.xcodeproj文件为基准,./表示与.xcodeproj同级,../表示上一级 2. 链接动态链接库 设置链接库,在Build Settin ...
- Nancy总结(一)Nancy一个轻量的MVC框架
Nancy是一个基于.net 和Mono 构建的HTTP服务框架,是一个非常轻量级的web框架. 设计用于处理 DELETE, GET, HEAD, OPTIONS, POST, PUT 和 PATC ...
- APP抓链接工具(Fiddler版)
1.下载Fiddler源代码: http://pan.baidu.com/s/1hqEUK0O 2.修改如下源代码: 3.运行截图:
- EF: Raw SQL Queries
Raw SQL Queries Entity Framework allows you to query using LINQ with your entity classes. However, t ...
- webuploader横向按钮样式
#picker{display: inline-block;line-height: 1.428571429;vertical-align: middle;margin: 0 12px 0 0;wid ...