[IOS笔记] - 动画animation
//移动
- (IBAction)translation:(id)sender {
CABasicAnimation *traslation = [CABasicAnimation animationWithKeyPath:@"position"];
traslation.toValue = [NSValue valueWithCGPoint:CGPointMake(,)];
traslation.duration = 2.0;
//traslation.autoreverses = YES;
traslation.repeatCount = ; [self.m_image.layer addAnimation:traslation forKey:@"traslation"];
} //透明
- (IBAction)opacity:(id)sender {
CABasicAnimation *opacity = [CABasicAnimation animationWithKeyPath:@"opacity"];
opacity.fromValue = [NSNumber numberWithFloat:1.0];
opacity.toValue = [NSNumber numberWithFloat:0.4];
opacity.duration = 0.2; //动画时间
opacity.repeatCount = FLT_MAX; //永久
opacity.autoreverses = YES; //每次动画后倒回回放
opacity.removedOnCompletion=NO; //动画后不还原,为no时不回到最初状态
opacity.fillMode=kCAFillModeForwards; [self.m_image.layer addAnimation:opacity forKey:@"opacity"];
} // 旋转
- (IBAction)rotate:(id)sender {
CATransform3D ca3d = CATransform3DMakeRotation( * 3.14159265/180.0, -, , ); CABasicAnimation *rotate = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
rotate.toValue = [NSValue valueWithCATransform3D:ca3d];
rotate.duration=1.0;
rotate.autoreverses=NO;
rotate.repeatCount=;
rotate.removedOnCompletion=NO;
rotate.fillMode=kCAFillModeForwards;
[self.m_image.layer addAnimation:rotate forKey:@"rotate"];
} - (IBAction)alpha:(id)sender {
} //缩放
- (IBAction)scale:(id)sender {
CABasicAnimation *scale = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
scale.fromValue=[NSNumber numberWithFloat:0.5];
scale.toValue = [NSNumber numberWithFloat:2.0];
scale.duration=1.0;
scale.autoreverses=YES;
scale.repeatCount=;
scale.removedOnCompletion=YES;
scale.fillMode=kCAFillModeForwards;
[self.m_image.layer addAnimation:scale forKey:@"scale"];
} //不按原始边长度缩放
-(IBAction)bounds:(id)sender{
CABasicAnimation *bounds = [CABasicAnimation animationWithKeyPath:@"bounds"];
bounds.duration = .f;
bounds.fromValue = [NSValue valueWithCGRect:CGRectMake(,,,)];
bounds.toValue = [NSValue valueWithCGRect:CGRectMake(,,,)];
bounds.byValue = [NSValue valueWithCGRect:self. m_image.bounds]; bounds.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
bounds.repeatCount = ;
bounds.autoreverses = YES; [self.m_image.layer addAnimation:bounds forKey:@"bounds"];
} - (IBAction)path:(id)sender {
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
CGMutablePathRef path = CGPathCreateMutable();
CGPathMoveToPoint(path, nil, , );
//添加直线路径
CGPathAddLineToPoint(path, NULL, , );
CGPathAddLineToPoint(path, NULL, , );
CGPathAddLineToPoint(path, NULL, , );
CGPathAddLineToPoint(path, NULL, , );
CGPathAddLineToPoint(path, NULL, , );
//添加曲线路径
CGPathAddCurveToPoint(path,NULL,50.0,275.0,150.0,275.0,70.0,120.0);
CGPathAddCurveToPoint(path,NULL,150.0,275.0,250.0,275.0,90.0,120.0);
CGPathAddCurveToPoint(path,NULL,250.0,275.0,350.0,275.0,110.0,120.0);
CGPathAddCurveToPoint(path,NULL,350.0,275.0,450.0,275.0,130.0,120.0); animation.path = path;
animation.duration = ;
animation.autoreverses = YES;
[self.m_image.layer addAnimation:animation forKey:@"path"];
CFRelease(path);
}
//组合动画
- (IBAction)goup:(id)sender {
CAAnimationGroup *group = [CAAnimationGroup animation]; CABasicAnimation *scale = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
scale.fromValue=[NSNumber numberWithFloat:0.5];
scale.toValue = [NSNumber numberWithFloat:2.0]; CABasicAnimation *traslation = [CABasicAnimation animationWithKeyPath:@"position"];
traslation.toValue = [NSValue valueWithCGPoint:CGPointMake(,)]; group.animations=[NSArray arrayWithObjects:scale, traslation, nil];
group.duration = 2.0; [self.m_image.layer addAnimation:group forKey:@"group"];
}
[IOS笔记] - 动画animation的更多相关文章
- 《The Cg Tutorial》阅读笔记——动画 Animation
这段时间阅读了英文版的NVidia官方的<The Cg Tutorial>,借此来学习基本的图形学知识和着色器编程. 在此做一个阅读笔记. 本文为大便一箩筐的原创内容,转载请注明出处,谢谢 ...
- iOS开发--动画(Animation)总结
UIView的,翻转.旋转,偏移,翻页,缩放,取反的动画效果 翻转的动画 //开始动画 [UIView beginAnimations:@"doflip" context:ni ...
- iOS开发动画(Animation)总结
UIView的,翻转.旋转,偏移,翻页,缩放,取反的动画效果 翻转的动画 //开始动画 [UIView beginAnimations:@"doflip" context:ni ...
- 荼菜的iOS笔记--UIView的几个Block动画
前言:我的第一篇文章荼菜的iOS笔记–Core Animation 核心动画算是比较详细讲了核心动画的用法,但是如你上篇看到的,有时我们只是想实现一些很小的动画,这时再用coreAnimation就会 ...
- Android动画学习笔记-Android Animation
Android动画学习笔记-Android Animation 3.0以前,android支持两种动画模式,tween animation,frame animation,在android3.0中 ...
- iOS 核心动画 Core Animation浅谈
代码地址如下:http://www.demodashi.com/demo/11603.html 前记 关于实现一个iOS动画,如果简单的,我们可以直接调用UIView的代码块来实现,虽然使用UIVie ...
- amazeui学习笔记--css(常用组件15)--CSS动画Animation
amazeui学习笔记--css(常用组件15)--CSS动画Animation 一.总结 1.css3动画封装:CSS3 动画封装,浏览器需支持 CSS3 动画. Class 描述 .am-anim ...
- iOS核心动画学习整理
最近利用业余时间终于把iOS核心动画高级技巧(https://zsisme.gitbooks.io/ios-/content/chapter1/the-layer-tree.html)看完,对应其中一 ...
- IOS 核心动画之CAKeyframeAnimation - iBaby
- IOS 核心动画之CAKeyframeAnimation - 简单介绍 是CApropertyAnimation的子类,跟CABasicAnimation的区别是:CABasicAnimation ...
随机推荐
- 开源OA系统启动:基础数据,工作流设计
原文:http://www.cnblogs.com/kwklover/archive/2007/01/13/bpoweroa_03_baseandworkflowdesign.html自从开源OA系统 ...
- LA 3667 Ruler 搜索
题意: 给出\(n\)个长度,要设计一个有\(m\)个刻度的刻度尺,刻度尺的刻度从\(0\)开始. 使得任意一个长度都能被该刻度尺度量出来. 首先要使\(m\)最小,在\(m\)最小的前提下尺子的长度 ...
- Java类编译、加载、和执行
https://www.cnblogs.com/fefjay/p/6305499.html
- shutil——高级的 文件、文件夹、压缩包 处理模块
高级的 文件.文件夹.压缩包 处理模块 shutil.copyfileobj(fsrc, fdst[, length])复制文件内容(不包含元数据)从类文件对象src到类文件对dst.可选参数leng ...
- Codecraft-18 and Codeforces Round #458 (Div. 1 + Div. 2, combined)
我真的是太菜了 A. Perfect Squares time limit per test 1 second memory limit per test 256 megabytes input st ...
- Eclipse调试程序及项目的导入导出
Eclipse调试程序 调试概述: ① 调试就是测试程序的方法,主要的目的就是解决程序的逻辑问题,流程是:发现问题.修改问题.正确执行; ② 以前我们可以使用System.out.printl ...
- Python 数据库到处到Excel
import MySQLdb import xlwt def outMySQL(file_name): wb = xlwt.Workbook() sh = wb.add_sheet('sheet 1' ...
- 【bzoj1954】Pku3764 The xor-longest Path Trie树
题目描述 给定一棵n个点的带权树,求树上最长的异或和路径 输入 The input contains several test cases. The first line of each test ...
- HDU-2448 Mining Station on the Sea
先根据不同的起点跑最短路,记录距离,从而建立二分图求最小匹配. 一开始我求最短路的时候我把港口直接加到图中,然后发现进了港口就不能出来了,所以连接港口的边就要从双向边改成单向边…………这也搞得我n和m ...
- js对象的扁平化与反扁平化
Object.flatten = function(obj){ var result = {}; function recurse(src, prop) { var toString = Object ...